aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_openssl.py
diff options
context:
space:
mode:
authorAndreas Moser <grrrrrrrrr@surfsup.at>2016-05-30 02:07:55 +0200
committerAlex Gaynor <alex.gaynor@gmail.com>2016-05-29 20:07:55 -0400
commit502f8f39cbadf88ca6494e68f90e1b7e937cdb3e (patch)
tree7273aa1ce7356816f4f61532b779f6ef06991d1f /tests/hazmat/backends/test_openssl.py
parentebe02ba61f2dadb1911b03fb3d4b214313c35d4d (diff)
downloadcryptography-502f8f39cbadf88ca6494e68f90e1b7e937cdb3e.tar.gz
cryptography-502f8f39cbadf88ca6494e68f90e1b7e937cdb3e.tar.bz2
cryptography-502f8f39cbadf88ca6494e68f90e1b7e937cdb3e.zip
Replacing test_osrandom_engine_is_default. (#2905)
* Removing test_osrandom_engine_is_default. test_osrandom_engine_is_default depends on having a valid sys.executable. This attribute is not always set (see https://docs.python.org/2/library/sys.html#sys.executable ) so, in some environments, this test fails. I moved the functionality of the test into the setup and teardown methods so the correct behavior is still tested. * Fixing some style issues. * Removing an unnecessary newline. * Putting back the test. * Moving the assert from teardown to setup.
Diffstat (limited to 'tests/hazmat/backends/test_openssl.py')
-rw-r--r--tests/hazmat/backends/test_openssl.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index 52bee7b3..a24f8ecd 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -208,6 +208,16 @@ class TestOpenSSL(object):
class TestOpenSSLRandomEngine(object):
+
+ def setup(self):
+ # The default RAND engine is global and shared between
+ # tests. We make sure that the default engine is osrandom
+ # before we start each test and restore the global state to
+ # that engine in teardown.
+ current_default = backend._lib.ENGINE_get_default_RAND()
+ name = backend._lib.ENGINE_get_name(current_default)
+ assert name == backend._binding._osrandom_engine_name
+
def teardown_method(self, method):
# we need to reset state to being default. backend is a shared global
# for all these tests.
@@ -216,6 +226,8 @@ class TestOpenSSLRandomEngine(object):
name = backend._lib.ENGINE_get_name(current_default)
assert name == backend._binding._osrandom_engine_name
+ @pytest.mark.skipif(sys.executable is None,
+ reason="No Python interpreter available.")
def test_osrandom_engine_is_default(self, tmpdir):
engine_printer = textwrap.dedent(
"""