summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-10-19 17:40:49 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-10-19 17:40:49 (GMT)
commit0fbd94ced92ca3cb09c130617fff7f8575de15e3 (patch)
tree5e70c0958c79812f26b8c5752047cc72452d26c4
parent55e092f545d3829e94eaf3d6aaaf048c82451e18 (diff)
downloadcpython-0fbd94ced92ca3cb09c130617fff7f8575de15e3.zip
cpython-0fbd94ced92ca3cb09c130617fff7f8575de15e3.tar.gz
cpython-0fbd94ced92ca3cb09c130617fff7f8575de15e3.tar.bz2
Issue #18582: skip test of _hashlib.pbkdf2_hmac if OpenSSL is not available or too old
-rw-r--r--Lib/test/test_hashlib.py19
1 files changed, 8 insertions, 11 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 18fe4b5..653f01c 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -548,8 +548,7 @@ class HashLibTestCase(unittest.TestCase):
self.assertEqual(expected_hash, hasher.hexdigest())
-class KDFTests:
- hashlibmod = None
+class KDFTests(unittest.TestCase):
pbkdf2_test_vectors = [
(b'password', b'salt', 1, None),
@@ -600,9 +599,7 @@ class KDFTests:
(bytes.fromhex('9d9e9c4cd21fe4be24d5b8244c759665'), None),],
}
- def test_pbkdf2_hmac(self):
- pbkdf2 = self.hashlibmod.pbkdf2_hmac
-
+ def _test_pbkdf2_hmac(self, pbkdf2):
for digest_name, results in self.pbkdf2_results.items():
for i, vector in enumerate(self.pbkdf2_test_vectors):
password, salt, rounds, dklen = vector
@@ -631,13 +628,13 @@ class KDFTests:
with self.assertRaisesRegex(ValueError, 'unsupported hash type'):
pbkdf2('unknown', b'pass', b'salt', 1)
+ def test_pbkdf2_hmac_py(self):
+ self._test_pbkdf2_hmac(py_hashlib.pbkdf2_hmac)
-class PyKDFTests(KDFTests, unittest.TestCase):
- hashlibmod = py_hashlib
-
-
-class CKDFTests(KDFTests, unittest.TestCase):
- hashlibmod = c_hashlib
+ @unittest.skipUnless(hasattr(c_hashlib, 'pbkdf2_hmac'),
+ ' test requires OpenSSL > 1.0')
+ def test_pbkdf2_hmac_c(self):
+ self._test_pbkdf2_hmac(c_hashlib.pbkdf2_hmac)
if __name__ == "__main__":