python-cryptography/python-cryptography-0.7.2-t...

40 lines
1.7 KiB
Diff

From e8179e79bcb1d8d6e09fffe8e0123afce09ce02d Mon Sep 17 00:00:00 2001
From: Donald Stufft <donald@stufft.io>
Date: Thu, 19 Feb 2015 22:37:49 -0500
Subject: [PATCH] Pass the sys.path into the subprocess
If we're running tests via ``python setup.py test`` in a clean
environment then all of our dependencies are going to be installed
into either the current directory or the .eggs directory. However the
subprocess won't know to activate these dependencies, so we'll get it
to do so by passing our entire sys.path into the subprocess via the
PYTHONPATH environment variable.
---
tests/hazmat/backends/test_openssl.py | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/tests/hazmat/backends/test_openssl.py b/tests/hazmat/backends/test_openssl.py
index 2bf66a0..0e4d75e 100644
--- a/tests/hazmat/backends/test_openssl.py
+++ b/tests/hazmat/backends/test_openssl.py
@@ -234,9 +234,19 @@ def test_osrandom_engine_is_default(self, tmpdir):
)
engine_name = tmpdir.join('engine_name')
+ # If we're running tests via ``python setup.py test`` in a clean
+ # environment then all of our dependencies are going to be installed
+ # into either the current directory or the .eggs directory. However the
+ # subprocess won't know to activate these dependencies, so we'll get it
+ # to do so by passing our entire sys.path into the subprocess via the
+ # PYTHONPATH environment variable.
+ env = os.environ.copy()
+ env["PYTHONPATH"] = os.pathsep.join(sys.path)
+
with engine_name.open('w') as out:
subprocess.check_call(
[sys.executable, "-c", engine_printer],
+ env=env,
stdout=out
)