diff options
| author | Steve Dower <steve.dower@microsoft.com> | 2018-09-20 20:38:34 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-20 20:38:34 (GMT) |
| commit | f14c28f39766855420dd58d209da4ad847f3030e (patch) | |
| tree | 79b95924f711b99388b2899c119ae31f31ad2ce5 /Lib/test/test_sysconfig.py | |
| parent | bc854750589d4de0fd55693963964e0558b5c8ac (diff) | |
| download | cpython-f14c28f39766855420dd58d209da4ad847f3030e.zip cpython-f14c28f39766855420dd58d209da4ad847f3030e.tar.gz cpython-f14c28f39766855420dd58d209da4ad847f3030e.tar.bz2 | |
bpo-34011: Fixes missing venv files and other tests (GH-9458)
Diffstat (limited to 'Lib/test/test_sysconfig.py')
| -rw-r--r-- | Lib/test/test_sysconfig.py | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 20252be..1b19298 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -235,21 +235,34 @@ class TestSysConfig(unittest.TestCase): def test_symlink(self): # On Windows, the EXE needs to know where pythonXY.dll is at so we have # to add the directory to the path. + env = None if sys.platform == "win32": - os.environ["PATH"] = "{};{}".format( - os.path.dirname(sys.executable), os.environ["PATH"]) + env = {k.upper(): os.environ[k] for k in os.environ} + env["PATH"] = "{};{}".format( + os.path.dirname(sys.executable), env.get("PATH", "")) + # Requires PYTHONHOME as well since we locate stdlib from the + # EXE path and not the DLL path (which should be fixed) + env["PYTHONHOME"] = os.path.dirname(sys.executable) + if sysconfig.is_python_build(True): + env["PYTHONPATH"] = os.path.dirname(os.__file__) # Issue 7880 - def get(python): + def get(python, env=None): cmd = [python, '-c', 'import sysconfig; print(sysconfig.get_platform())'] - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=os.environ) - return p.communicate() + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, env=env) + out, err = p.communicate() + if p.returncode: + print((out, err)) + self.fail('Non-zero return code {0} (0x{0:08X})' + .format(p.returncode)) + return out, err real = os.path.realpath(sys.executable) link = os.path.abspath(TESTFN) os.symlink(real, link) try: - self.assertEqual(get(real), get(link)) + self.assertEqual(get(real), get(link, env)) finally: unlink(link) |
