diff options
author | David Reid <dreid@dreid.org> | 2014-06-13 11:18:02 -0700 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2014-06-13 11:18:02 -0700 |
commit | fea104bc505baf2a648d37f7da9ab48d1a5212a0 (patch) | |
tree | e1fe025c039c5412d3825af0adf7cae85eccb73d /tests/hazmat | |
parent | 1d20fc0cc77ae4e5da6bca1b8ac5396cb4c011ea (diff) | |
download | cryptography-fea104bc505baf2a648d37f7da9ab48d1a5212a0.tar.gz cryptography-fea104bc505baf2a648d37f7da9ab48d1a5212a0.tar.bz2 cryptography-fea104bc505baf2a648d37f7da9ab48d1a5212a0.zip |
Portable usage of subprocess w/ python3 and python2.6 fixes.
Diffstat (limited to 'tests/hazmat')
-rw-r--r-- | tests/hazmat/backends/test_openssl.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py index 2d953597..75369efc 100644 --- a/tests/hazmat/backends/test_openssl.py +++ b/tests/hazmat/backends/test_openssl.py @@ -216,7 +216,7 @@ class TestOpenSSLRandomEngine(object): name = backend._lib.ENGINE_get_name(current_default) assert name == backend._lib.Cryptography_osrandom_engine_name - def test_osrandom_engine_is_default(self): + def test_osrandom_engine_is_default(self, tmpdir): engine_printer = textwrap.dedent( """ import sys @@ -224,21 +224,24 @@ class TestOpenSSLRandomEngine(object): e = backend._lib.ENGINE_get_default_RAND() name = backend._lib.ENGINE_get_name(e) - sys.stdout.write(backend._ffi.string(name)) + sys.stdout.write(backend._ffi.string(name).decode('ascii')) res = backend._lib.ENGINE_free(e) assert res == 1 """ ) + engine_name = tmpdir.join('engine_name') - engine_name = subprocess.check_output( - [sys.executable, "-c", engine_printer] - ) + with engine_name.open('w') as out: + subprocess.check_call( + [sys.executable, "-c", engine_printer], + stdout=out + ) osrandom_engine_name = backend._ffi.string( backend._lib.Cryptography_osrandom_engine_name ) - assert engine_name == osrandom_engine_name + assert engine_name.read().encode('ascii') == osrandom_engine_name def test_osrandom_sanity_check(self): # This test serves as a check against catastrophic failure. |