2013-12-25 04:23:53 +00:00
|
|
|
import pytest
|
|
|
|
|
|
2014-01-10 22:39:12 +00:00
|
|
|
from cryptography.hazmat.backends import _ALL_BACKENDS
|
2013-12-25 04:23:53 +00:00
|
|
|
from cryptography.hazmat.backends.interfaces import (
|
2014-02-08 15:21:21 +00:00
|
|
|
HMACBackend, CipherBackend, HashBackend, PBKDF2HMACBackend, RSABackend
|
2013-12-25 04:23:53 +00:00
|
|
|
)
|
|
|
|
|
|
2014-01-18 15:22:21 +00:00
|
|
|
from .utils import check_for_iface, check_backend_support, select_backends
|
2014-01-14 02:52:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_generate_tests(metafunc):
|
2014-01-18 15:22:21 +00:00
|
|
|
names = metafunc.config.getoption("--backend")
|
2014-01-19 18:09:27 +00:00
|
|
|
selected_backends = select_backends(names, _ALL_BACKENDS)
|
2013-12-25 04:23:53 +00:00
|
|
|
|
2014-01-19 18:09:27 +00:00
|
|
|
if "backend" in metafunc.fixturenames:
|
|
|
|
|
metafunc.parametrize("backend", selected_backends)
|
2013-12-25 04:23:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.trylast
|
|
|
|
|
def pytest_runtest_setup(item):
|
2013-12-25 05:55:24 +00:00
|
|
|
check_for_iface("hmac", HMACBackend, item)
|
|
|
|
|
check_for_iface("cipher", CipherBackend, item)
|
|
|
|
|
check_for_iface("hash", HashBackend, item)
|
2014-01-28 23:09:59 +00:00
|
|
|
check_for_iface("pbkdf2hmac", PBKDF2HMACBackend, item)
|
2014-02-08 15:21:21 +00:00
|
|
|
check_for_iface("rsa", RSABackend, item)
|
2013-12-27 02:19:34 +00:00
|
|
|
check_backend_support(item)
|
2014-01-14 02:52:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--backend", action="store", metavar="NAME",
|
|
|
|
|
help="Only run tests matching the backend NAME."
|
|
|
|
|
)
|