blob: 5cc304288323f28630d339d4d3847b730786b3be [file] [log] [blame]
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -06001import pytest
2
Alex Stapleton0d583732014-01-10 22:39:12 +00003from cryptography.hazmat.backends import _ALL_BACKENDS
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -06004from cryptography.hazmat.backends.interfaces import (
5 HMACBackend, CipherBackend, HashBackend
6)
7
Paul Kehrer34c075e2014-01-13 21:52:08 -05008from .utils import check_for_iface, check_backend_support, modify_backend_list
9
10
11def pytest_generate_tests(metafunc):
12 name = metafunc.config.getoption("--backend")
13 modify_backend_list(name, _ALL_BACKENDS)
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -060014
15
Alex Stapleton0d583732014-01-10 22:39:12 +000016@pytest.fixture(params=_ALL_BACKENDS)
17def backend(request):
18 return request.param
Paul Kehrer7e4bc6d2013-12-24 22:23:53 -060019
20
21@pytest.mark.trylast
22def pytest_runtest_setup(item):
Alex Gaynor2b3f9422013-12-24 21:55:24 -080023 check_for_iface("hmac", HMACBackend, item)
24 check_for_iface("cipher", CipherBackend, item)
25 check_for_iface("hash", HashBackend, item)
Paul Kehrer60fc8da2013-12-26 20:19:34 -060026 check_backend_support(item)
Paul Kehrer34c075e2014-01-13 21:52:08 -050027
28
29def pytest_addoption(parser):
30 parser.addoption(
31 "--backend", action="store", metavar="NAME",
32 help="Only run tests matching the backend NAME."
33 )