diff options
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 66a3cd64..c21f4dcc 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -8,30 +8,28 @@ import pytest from cryptography.hazmat.backends.openssl import backend as openssl_backend -from .utils import check_backend_support, skip_if_empty +from .utils import check_backend_support def pytest_report_header(config): return "OpenSSL: {0}".format(openssl_backend.openssl_version_text()) -def pytest_generate_tests(metafunc): - if "backend" in metafunc.fixturenames: - filtered_backends = [] - required_interfaces = [ - mark.kwargs["interface"] - for mark in metafunc.function.requires_backend_interface - ] - if all( - isinstance(openssl_backend, iface) for iface in required_interfaces - ): - filtered_backends.append(openssl_backend) - - # If you pass an empty list to parametrize Bad Things(tm) happen - # as of pytest 2.6.4 when the test also has a parametrize decorator - skip_if_empty(filtered_backends, required_interfaces) - - metafunc.parametrize("backend", filtered_backends) +@pytest.fixture() +def backend(request): + required_interfaces = [ + mark.kwargs["interface"] + for mark in request.node.get_marker("requires_backend_interface") + ] + if all( + isinstance(openssl_backend, iface) for iface in required_interfaces + ): + return openssl_backend + pytest.skip( + "OpenSSL doesn't implement required interfaces: {0}".format( + required_interfaces + ) + ) @pytest.mark.trylast |