diff options
author | Colin Watson <cjwatson@debian.org> | 2020-03-02 11:47:34 +0100 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2020-03-02 11:47:34 +0100 |
commit | 2c0d6f05ed118e64097ee9d0e1237a18c066c9e3 (patch) | |
tree | b62e6c0f646dce68afd2c5604ba62fa698f0ca97 | |
parent | 557dc2eac99b29feda2c7f207f7ad6cbe90dde09 (diff) | |
download | openid-2c0d6f05ed118e64097ee9d0e1237a18c066c9e3.tar.gz |
Quieten some noisy deprecation warnings in tests
-rw-r--r-- | openid/test/test_cryptutil.py | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/openid/test/test_cryptutil.py b/openid/test/test_cryptutil.py index 106be42..f0caed5 100644 --- a/openid/test/test_cryptutil.py +++ b/openid/test/test_cryptutil.py @@ -5,6 +5,7 @@ import os.path import random import sys import unittest +import warnings import six @@ -18,15 +19,17 @@ class TestLongBinary(unittest.TestCase): def test_binaryLongConvert(self): MAX = sys.maxsize - for iteration in range(500): - n = 0 - for i in range(10): - n += random.randrange(MAX) - - s = cryptutil.longToBinary(n) - assert isinstance(s, six.binary_type) - n_prime = cryptutil.binaryToLong(s) - assert n == n_prime, (n, n_prime) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', category=DeprecationWarning) + for iteration in range(500): + n = 0 + for i in range(10): + n += random.randrange(MAX) + + s = cryptutil.longToBinary(n) + assert isinstance(s, six.binary_type) + n_prime = cryptutil.binaryToLong(s) + assert n == n_prime, (n, n_prime) cases = [ (b'\x00', 0), @@ -39,11 +42,13 @@ class TestLongBinary(unittest.TestCase): (b'OpenID is cool', 1611215304203901150134421257416556) ] - for s, n in cases: - n_prime = cryptutil.binaryToLong(s) - s_prime = cryptutil.longToBinary(n) - assert n == n_prime, (s, n, n_prime) - assert s == s_prime, (n, s, s_prime) + with warnings.catch_warnings(): + warnings.simplefilter('ignore', category=DeprecationWarning) + for s, n in cases: + n_prime = cryptutil.binaryToLong(s) + s_prime = cryptutil.longToBinary(n) + assert n == n_prime, (s, n, n_prime) + assert s == s_prime, (n, s, s_prime) class TestFixBtwoc(unittest.TestCase): |