From 502f8f39cbadf88ca6494e68f90e1b7e937cdb3e Mon Sep 17 00:00:00 2001 From: Andreas Moser Date: Mon, 30 May 2016 02:07:55 +0200 Subject: 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. --- tests/hazmat/backends/test_openssl.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/hazmat/backends/test_openssl.py') 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( """ -- cgit v1.2.3