diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-27 16:16:41 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2013-12-27 16:16:41 -0800 |
commit | 7ede6a4b80677bf56088b8492fa87b19183db448 (patch) | |
tree | a779758c943ba22310b8ba3bd7b3202446417503 /tests/test_utils.py | |
parent | 9b51cc1a843d6a8427eb4ad49aeaf5317c442fed (diff) | |
parent | b078d8e1f446a1d2d13453e65e37fbaf4f6b17f2 (diff) | |
download | cryptography-7ede6a4b80677bf56088b8492fa87b19183db448.tar.gz cryptography-7ede6a4b80677bf56088b8492fa87b19183db448.tar.bz2 cryptography-7ede6a4b80677bf56088b8492fa87b19183db448.zip |
Merge pull request #353 from reaperhulk/supported-mark
Add mark that allows us to do skip tests on backends via decorators
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index a65091ff..c640367e 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -20,7 +20,8 @@ import pytest from .utils import ( load_nist_vectors, load_vectors_from_file, load_cryptrec_vectors, - load_openssl_vectors, load_hash_vectors, check_for_iface + load_openssl_vectors, load_hash_vectors, check_for_iface, + check_backend_support ) @@ -41,6 +42,36 @@ def test_check_for_iface(): check_for_iface("fake_name", FakeInterface, item) +def test_check_backend_support_skip(): + supported = pretend.stub( + kwargs={"only_if": lambda backend: False, "skip_message": "Nope"} + ) + item = pretend.stub(keywords={"supported": supported}, + funcargs={"backend": True}) + with pytest.raises(pytest.skip.Exception) as exc_info: + check_backend_support(item) + assert exc_info.value.args[0] == "Nope" + + +def test_check_backend_support_no_skip(): + supported = pretend.stub( + kwargs={"only_if": lambda backend: True, "skip_message": "Nope"} + ) + item = pretend.stub(keywords={"supported": supported}, + funcargs={"backend": True}) + assert check_backend_support(item) is None + + +def test_check_backend_support_no_backend(): + supported = pretend.stub( + kwargs={"only_if": "notalambda", "skip_message": "Nope"} + ) + item = pretend.stub(keywords={"supported": supported}, + funcargs={}) + with pytest.raises(ValueError): + check_backend_support(item) + + def test_load_nist_vectors(): vector_data = textwrap.dedent(""" # CAVS 11.1 |