From 512dd6925202c5dc6680dd7157a132a9ffc4855f Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 16 Oct 2013 14:27:52 -0700 Subject: Move around the skip logic --- tests/primitives/utils.py | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'tests/primitives/utils.py') diff --git a/tests/primitives/utils.py b/tests/primitives/utils.py index addd7123..e4cb8da7 100644 --- a/tests/primitives/utils.py +++ b/tests/primitives/utils.py @@ -8,19 +8,28 @@ from cryptography.primitives.block import BlockCipher def generate_encrypt_test(param_loader, path, file_names, cipher_factory, - mode_factory, only_if=lambda api: True): + mode_factory, only_if=lambda api: True, + skip_message=None): def test_encryption(self): for api in _ALL_APIS: - if not only_if(api): - yield encrypt_skipped - else: - for file_name in file_names: - for params in param_loader(os.path.join(path, file_name)): - yield encrypt_test, api, cipher_factory, mode_factory, params + for file_name in file_names: + for params in param_loader(os.path.join(path, file_name)): + yield ( + encrypt_test, + api, + cipher_factory, + mode_factory, + params, + only_if, + skip_message + ) return test_encryption -def encrypt_test(api, cipher_factory, mode_factory, params): +def encrypt_test(api, cipher_factory, mode_factory, params, only_if, + skip_message): + if not only_if(api): + pytest.skip(skip_message) plaintext = params.pop("plaintext") ciphertext = params.pop("ciphertext") cipher = BlockCipher( @@ -31,7 +40,3 @@ def encrypt_test(api, cipher_factory, mode_factory, params): actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext)) actual_ciphertext += cipher.finalize() assert binascii.hexlify(actual_ciphertext) == ciphertext - - -def encrypt_skipped(): - pytest.skip("because reasons") -- cgit v1.2.3