aboutsummaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-10-24 07:49:33 -0700
committerAlex Gaynor <alex.gaynor@gmail.com>2014-10-24 07:49:33 -0700
commitf484d1ef03bc548dde300a59c91474d82169b1be (patch)
treef3d79d1c6a22db5b90a5810ffe1a432be9c912df /tests/conftest.py
parent971b98d40ed1cb6b6eecba7a83c0ff4a1ef89c5f (diff)
parent2f2346344ae5561bc9b106cbb452efeebe3cdc45 (diff)
downloadcryptography-f484d1ef03bc548dde300a59c91474d82169b1be.tar.gz
cryptography-f484d1ef03bc548dde300a59c91474d82169b1be.tar.bz2
cryptography-f484d1ef03bc548dde300a59c91474d82169b1be.zip
Merge branch 'master' into verify-interfaces
Conflicts: cryptography/hazmat/primitives/hmac.py
Diffstat (limited to 'tests/conftest.py')
-rw-r--r--tests/conftest.py35
1 files changed, 13 insertions, 22 deletions
diff --git a/tests/conftest.py b/tests/conftest.py
index b7981c9d..20926024 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:
+ required_interfaces = tuple(
+ mark.kwargs["interface"] for mark in required
+ )
+ if not isinstance(item.funcargs["backend"], required_interfaces):
+ pytest.skip("{0} backend does not support {1}".format(
+ item.funcargs["backend"],
+ ", ".join(iface.__name__ for iface in required_interfaces)
+ ))
+
check_backend_support(item)