aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/bindings/test_openssl.py
diff options
context:
space:
mode:
authorAlex Stapleton <alexs@prol.etari.at>2014-01-23 20:43:49 +0000
committerAlex Stapleton <alexs@prol.etari.at>2014-01-24 08:11:45 +0000
commit7ce51f26bb10dc56483a5f0e9639092ccb2f9d5c (patch)
treedc28f091ca3850c0786fb2c03ad780939a8e0a15 /tests/hazmat/bindings/test_openssl.py
parentfcae15014dd9510969615a7f5100704955bbeb64 (diff)
downloadcryptography-7ce51f26bb10dc56483a5f0e9639092ccb2f9d5c.tar.gz
cryptography-7ce51f26bb10dc56483a5f0e9639092ccb2f9d5c.tar.bz2
cryptography-7ce51f26bb10dc56483a5f0e9639092ccb2f9d5c.zip
Split a test in half
Diffstat (limited to 'tests/hazmat/bindings/test_openssl.py')
-rw-r--r--tests/hazmat/bindings/test_openssl.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/hazmat/bindings/test_openssl.py b/tests/hazmat/bindings/test_openssl.py
index e5094133..43a07760 100644
--- a/tests/hazmat/bindings/test_openssl.py
+++ b/tests/hazmat/bindings/test_openssl.py
@@ -35,14 +35,20 @@ class TestOpenSSL(object):
lock_cb = b.lib.CRYPTO_get_locking_callback()
assert lock_cb != b.ffi.NULL
- def test_our_crypto_lock(self, capfd):
- b = Binding()
- b.init_static_locks()
-
+ def _skip_if_not_fallback_lock(self, b):
# only run this test if we are using our locking cb
original_cb = b.lib.CRYPTO_get_locking_callback()
if original_cb != b._lock_cb_handle:
- pytest.skip("Not using Python locking callback implementation")
+ pytest.skip(
+ "Not using the fallback Python locking callback "
+ "implementation. Probably because import _ssl set one"
+ )
+
+ def test_fallback_crypto_lock_via_openssl_api(self):
+ b = Binding()
+ b.init_static_locks()
+
+ self._skip_if_not_fallback_lock(b)
# check that the lock state changes appropriately
lock = b._locks[b.lib.CRYPTO_LOCK_SSL]
@@ -68,7 +74,13 @@ class TestOpenSSL(object):
assert lock.acquire(False)
lock.release()
- # then test directly
+ def test_fallback_crypto_lock_via_binding_api(self):
+ b = Binding()
+ b.init_static_locks()
+
+ self._skip_if_not_fallback_lock(b)
+
+ lock = b._locks[b.lib.CRYPTO_LOCK_SSL]
with pytest.raises(RuntimeError):
b._lock_cb(0, b.lib.CRYPTO_LOCK_SSL, "<test>", 1)