diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-23 11:01:25 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-23 11:01:25 -0700 |
commit | 7aab8b4ae4f5ab1710a985551c4105d608f5b852 (patch) | |
tree | fc0e9096c155374259b88f3d3404083f992e8836 /tests/conftest.py | |
parent | a05af52d1f0fba90030b62185d38523119d68b42 (diff) | |
download | pyca-cryptography-7aab8b4ae4f5ab1710a985551c4105d608f5b852.zip pyca-cryptography-7aab8b4ae4f5ab1710a985551c4105d608f5b852.tar.gz pyca-cryptography-7aab8b4ae4f5ab1710a985551c4105d608f5b852.tar.bz2 |
Change how we represented that a test requires a backend.
This way is more extensible and requires less maintaince
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index b7981c9..7f8e71d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -16,13 +16,8 @@ from __future__ import absolute_import, division, print_function import pytest from cryptography.hazmat.backends import _available_backends -from cryptography.hazmat.backends.interfaces import ( - CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, - HashBackend, PBKDF2HMACBackend, PEMSerializationBackend, - PKCS8SerializationBackend, RSABackend, - TraditionalOpenSSLSerializationBackend -) -from .utils import check_backend_support, check_for_iface, select_backends + +from .utils import check_backend_support, select_backends def pytest_generate_tests(metafunc): @@ -35,21 +30,17 @@ def pytest_generate_tests(metafunc): @pytest.mark.trylast def pytest_runtest_setup(item): - check_for_iface("hmac", HMACBackend, item) - check_for_iface("cipher", CipherBackend, item) - check_for_iface("cmac", CMACBackend, item) - check_for_iface("hash", HashBackend, item) - check_for_iface("pbkdf2hmac", PBKDF2HMACBackend, item) - check_for_iface("dsa", DSABackend, item) - check_for_iface("rsa", RSABackend, item) - check_for_iface( - "traditional_openssl_serialization", - TraditionalOpenSSLSerializationBackend, - item - ) - check_for_iface("pkcs8_serialization", PKCS8SerializationBackend, item) - check_for_iface("elliptic", EllipticCurveBackend, item) - check_for_iface("pem_serialization", PEMSerializationBackend, item) + required = item.keywords.get("requires_backend_interface") + if ( + required is not None and + "backend" in item.funcargs and + not isinstance(item.funcargs["backend"], required.kwargs['interface']) + ): + pytest.skip("{0} backend does not support {1}".format( + item.funcargs["backend"], + required.kwargs['interface'].__name__ + )) + check_backend_support(item) |