diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-04 13:37:00 -0600 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-04 17:21:29 -0600 |
commit | 108605b01873c4176275cc6bf2ea0d0b7c447a0e (patch) | |
tree | 1d175ea3a755fde33110bbd11aa0d51ff38b4a12 /tests/test_utils.py | |
parent | d68fd37ec18c5adfa580d989730f7988d72d2bea (diff) | |
download | cryptography-108605b01873c4176275cc6bf2ea0d0b7c447a0e.tar.gz cryptography-108605b01873c4176275cc6bf2ea0d0b7c447a0e.tar.bz2 cryptography-108605b01873c4176275cc6bf2ea0d0b7c447a0e.zip |
add commoncrypto mark to skip on non-OS X platforms
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index e3e53d63..917e87f0 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -14,14 +14,18 @@ import os import textwrap +import cffi + import pretend import pytest +from cryptography.hazmat.bindings.utils import binding_available + from .utils import ( load_nist_vectors, load_vectors_from_file, load_cryptrec_vectors, load_openssl_vectors, load_hash_vectors, check_for_iface, - check_backend_support + check_backend_support, check_binding_available ) @@ -72,6 +76,31 @@ def test_check_backend_support_no_backend(): check_backend_support(item) +def test_check_binding_available(): + from cryptography.hazmat.bindings.openssl.binding import Binding + kwargs = pretend.stub(kwargs={"binding": Binding}) + item = pretend.stub(keywords={"binding_available": kwargs}) + assert check_binding_available(item) is None + + +def test_check_binding_unavailable(): + class FakeBinding(object): + @classmethod + def _ensure_ffi_initialized(cls): + raise cffi.VerificationError + + @classmethod + def is_available(cls): + return binding_available(cls._ensure_ffi_initialized) + + kwargs = pretend.stub(kwargs={"binding": FakeBinding}) + item = pretend.stub(keywords={"binding_available": kwargs}) + with pytest.raises(pytest.skip.Exception) as exc_info: + check_binding_available(item) + assert exc_info.value.args[0] == ("<class 'tests.test_utils.FakeBinding'>" + " is not available") + + def test_load_nist_vectors(): vector_data = textwrap.dedent(""" # CAVS 11.1 |