aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2013-10-19 19:49:30 -0400
committerDonald Stufft <donald@stufft.io>2013-10-19 19:49:30 -0400
commit2acd77aa20b3a6e8eacf33d6e0cc7df4b438799d (patch)
tree81d1fe93e2b958c11213a96bbfad423d641b02a4 /tests
parent3359d7efdc5e96ae25c69226a2a1452a8f6641f7 (diff)
downloadcryptography-2acd77aa20b3a6e8eacf33d6e0cc7df4b438799d.tar.gz
cryptography-2acd77aa20b3a6e8eacf33d6e0cc7df4b438799d.tar.bz2
cryptography-2acd77aa20b3a6e8eacf33d6e0cc7df4b438799d.zip
Only execute only_if if we need to
Diffstat (limited to 'tests')
-rw-r--r--tests/primitives/utils.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py
index 8b32700b..a3759b03 100644
--- a/tests/primitives/utils.py
+++ b/tests/primitives/utils.py
@@ -43,7 +43,7 @@ def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
def generate_hash_test(param_loader, path, file_names, hash_cls,
- only_if=lambda api: True, skip_message=None):
+ only_if=None, skip_message=None):
def test_hash(self):
for api in _ALL_APIS:
for file_name in file_names:
@@ -60,7 +60,7 @@ def generate_hash_test(param_loader, path, file_names, hash_cls,
def hash_test(api, hash_cls, params, only_if, skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
msg = params[0]
md = params[1]
@@ -70,7 +70,7 @@ def hash_test(api, hash_cls, params, only_if, skip_message):
def generate_base_hash_test(hash_cls, digest_size, block_size,
- only_if=lambda api: True, skip_message=None):
+ only_if=None, skip_message=None):
def test_base_hash(self):
for api in _ALL_APIS:
yield (
@@ -87,7 +87,7 @@ def generate_base_hash_test(hash_cls, digest_size, block_size,
def base_hash_test(api, hash_cls, digest_size, block_size, only_if,
skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
m = hash_cls(api=api)
assert m.digest_size == digest_size
@@ -97,7 +97,7 @@ def base_hash_test(api, hash_cls, digest_size, block_size, only_if,
assert m._ctx != m_copy._ctx
-def generate_long_string_hash_test(hash_factory, md, only_if=lambda api: True,
+def generate_long_string_hash_test(hash_factory, md, only_if=None,
skip_message=None):
def test_long_string_hash(self):
for api in _ALL_APIS:
@@ -113,7 +113,7 @@ def generate_long_string_hash_test(hash_factory, md, only_if=lambda api: True,
def long_string_hash_test(api, hash_factory, md, only_if, skip_message):
- if not only_if(api):
+ if only_if is not None and not only_if(api):
pytest.skip(skip_message)
m = hash_factory(api)
m.update(b"a" * 1000000)