diff options
author | David Reid <dreid@dreid.org> | 2014-01-20 10:14:40 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2014-01-20 10:14:40 -0800 |
commit | cd10571261ad24dcd0dc63c9703289faccd841a8 (patch) | |
tree | 5994b0a095af99749e05ee936f8932af9a86ff40 /tests/conftest.py | |
parent | 580e992dc0d95618d3e667e471dd1d6a7eb6e323 (diff) | |
parent | ad4f646e685beb38e597bab83ea8e8314a3fd581 (diff) | |
download | cryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.tar.gz cryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.tar.bz2 cryptography-cd10571261ad24dcd0dc63c9703289faccd841a8.zip |
Merge pull request #468 from reaperhulk/backend-flag-pytest
Add backend flag for pytest runs
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index 1d9f96ed..a9acb54a 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,12 +5,15 @@ from cryptography.hazmat.backends.interfaces import ( HMACBackend, CipherBackend, HashBackend ) -from .utils import check_for_iface, check_backend_support +from .utils import check_for_iface, check_backend_support, select_backends -@pytest.fixture(params=_ALL_BACKENDS) -def backend(request): - return request.param +def pytest_generate_tests(metafunc): + names = metafunc.config.getoption("--backend") + selected_backends = select_backends(names, _ALL_BACKENDS) + + if "backend" in metafunc.fixturenames: + metafunc.parametrize("backend", selected_backends) @pytest.mark.trylast @@ -19,3 +22,10 @@ def pytest_runtest_setup(item): check_for_iface("cipher", CipherBackend, item) check_for_iface("hash", HashBackend, item) check_backend_support(item) + + +def pytest_addoption(parser): + parser.addoption( + "--backend", action="store", metavar="NAME", + help="Only run tests matching the backend NAME." + ) |