aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2017-06-03 20:38:22 -0400
committerPaul Kehrer <paul.l.kehrer@gmail.com>2017-06-03 14:38:22 -1000
commit133a17971af3c40ff935be5c74ba2542cebbea30 (patch)
tree8d1837008d4508e897bf856fac9dad5562c6ac11 /tests/conftest.py
parentcb175069bfa921503d79f12399948173bf247779 (diff)
downloadcryptography-133a17971af3c40ff935be5c74ba2542cebbea30.tar.gz
cryptography-133a17971af3c40ff935be5c74ba2542cebbea30.tar.bz2
cryptography-133a17971af3c40ff935be5c74ba2542cebbea30.zip
Switched our backend to be a normal fixture in tests (#3665)
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py34
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