Commit 92dcb8df authored by Robert Bradshaw's avatar Robert Bradshaw

Simplify environment handling in srctree tests.

parent eb0e4666
...@@ -1525,25 +1525,21 @@ class EndToEndTest(unittest.TestCase): ...@@ -1525,25 +1525,21 @@ class EndToEndTest(unittest.TestCase):
.replace("CYTHON", "PYTHON %s" % os.path.join(self.cython_root, 'cython.py')) .replace("CYTHON", "PYTHON %s" % os.path.join(self.cython_root, 'cython.py'))
.replace("PYTHON", sys.executable)) .replace("PYTHON", sys.executable))
old_path = os.environ.get('PYTHONPATH') old_path = os.environ.get('PYTHONPATH')
os.environ['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '') env = dict(os.environ)
try: env['PYTHONPATH'] = self.cython_syspath + os.pathsep + (old_path or '')
for command in filter(None, commands.splitlines()): for command in filter(None, commands.splitlines()):
p = subprocess.Popen(command, p = subprocess.Popen(command,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
shell=True) shell=True,
out, err = p.communicate() env=env)
res = p.returncode out, err = p.communicate()
if res != 0: res = p.returncode
print(command) if res != 0:
print(self._try_decode(out)) print(command)
print(self._try_decode(err)) print(self._try_decode(out))
self.assertEqual(0, res, "non-zero exit status") print(self._try_decode(err))
finally: self.assertEqual(0, res, "non-zero exit status")
if old_path:
os.environ['PYTHONPATH'] = old_path
else:
del os.environ['PYTHONPATH']
self.success = True self.success = True
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment