diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-18 19:51:01 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2013-10-18 19:51:01 -0500 |
commit | bb069c2fee6460185ee435ea848d80bab2ccec6c (patch) | |
tree | 1adb549d825ae3095096c2d17c035cfdbef45cbe | |
parent | bde6fb52129909cf319157dba95d65fb557d5013 (diff) | |
download | cryptography-bb069c2fee6460185ee435ea848d80bab2ccec6c.tar.gz cryptography-bb069c2fee6460185ee435ea848d80bab2ccec6c.tar.bz2 cryptography-bb069c2fee6460185ee435ea848d80bab2ccec6c.zip |
remove unneeded lambdas from tests
-rw-r--r-- | tests/primitives/test_hash_vectors.py | 2 | ||||
-rw-r--r-- | tests/primitives/test_hashes.py | 2 | ||||
-rw-r--r-- | tests/primitives/utils.py | 16 |
3 files changed, 10 insertions, 10 deletions
diff --git a/tests/primitives/test_hash_vectors.py b/tests/primitives/test_hash_vectors.py index 4b71ad70..8198b086 100644 --- a/tests/primitives/test_hash_vectors.py +++ b/tests/primitives/test_hash_vectors.py @@ -29,7 +29,7 @@ class TestSHA1(object): "SHA1LongMsg.rsp", "SHA1ShortMsg.rsp", ], - lambda api: hashes.SHA1(api=api), + hashes.SHA1, only_if=lambda api: api.supports_hash("sha1"), skip_message="Does not support SHA1", ) diff --git a/tests/primitives/test_hashes.py b/tests/primitives/test_hashes.py index 3419b14d..1bc2e9e9 100644 --- a/tests/primitives/test_hashes.py +++ b/tests/primitives/test_hashes.py @@ -20,7 +20,7 @@ from .utils import generate_base_hash_test class TestSHA1(object): test_SHA1 = generate_base_hash_test( - lambda api: hashes.SHA1(api=api), + hashes.SHA1, digest_size=20, block_size=64, only_if=lambda api: api.supports_hash("sha1"), diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py index f301199c..0d4c0eb3 100644 --- a/tests/primitives/utils.py +++ b/tests/primitives/utils.py @@ -42,7 +42,7 @@ def encrypt_test(api, cipher_factory, mode_factory, params, only_if, assert actual_ciphertext == binascii.unhexlify(ciphertext) -def generate_hash_test(param_loader, path, file_names, hash_factory, +def generate_hash_test(param_loader, path, file_names, hash_cls, only_if=lambda api: True, skip_message=None): def test_hash(self): for api in _ALL_APIS: @@ -51,7 +51,7 @@ def generate_hash_test(param_loader, path, file_names, hash_factory, yield ( hash_test, api, - hash_factory, + hash_cls, params, only_if, skip_message @@ -59,24 +59,24 @@ def generate_hash_test(param_loader, path, file_names, hash_factory, return test_hash -def hash_test(api, hash_factory, params, only_if, skip_message): +def hash_test(api, hash_cls, params, only_if, skip_message): if not only_if(api): pytest.skip(skip_message) msg = params[0] md = params[1] - m = hash_factory(api) + m = hash_cls(api=api) m.update(binascii.unhexlify(msg)) assert m.hexdigest() == md.replace(" ", "").lower() -def generate_base_hash_test(hash_factory, digest_size, block_size, +def generate_base_hash_test(hash_cls, digest_size, block_size, only_if=lambda api: True, skip_message=None): def test_base_hash(self): for api in _ALL_APIS: yield ( base_hash_test, api, - hash_factory, + hash_cls, digest_size, block_size, only_if, @@ -85,11 +85,11 @@ def generate_base_hash_test(hash_factory, digest_size, block_size, return test_base_hash -def base_hash_test(api, hash_factory, digest_size, block_size, only_if, +def base_hash_test(api, hash_cls, digest_size, block_size, only_if, skip_message): if not only_if(api): pytest.skip(skip_message) - m = hash_factory(api=api) + m = hash_cls(api=api) assert m.digest_size == digest_size assert m.block_size == block_size m_copy = m.copy() |