diff options
Diffstat (limited to 'Lib/test/test_sysconfig.py')
-rw-r--r-- | Lib/test/test_sysconfig.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py index 1b1929885e..51bef19000 100644 --- a/Lib/test/test_sysconfig.py +++ b/Lib/test/test_sysconfig.py @@ -233,16 +233,26 @@ class TestSysConfig(unittest.TestCase): @skip_unless_symlink def test_symlink(self): + if sys.platform == "win32" and not os.path.exists(sys.executable): + # App symlink appears to not exist, but we want the + # real executable here anyway + import _winapi + real = _winapi.GetModuleFileName(0) + else: + real = os.path.realpath(sys.executable) + link = os.path.abspath(TESTFN) + os.symlink(real, link) + # 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": env = {k.upper(): os.environ[k] for k in os.environ} env["PATH"] = "{};{}".format( - os.path.dirname(sys.executable), env.get("PATH", "")) + os.path.dirname(real), 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) + env["PYTHONHOME"] = os.path.dirname(real) if sysconfig.is_python_build(True): env["PYTHONPATH"] = os.path.dirname(os.__file__) @@ -258,9 +268,6 @@ class TestSysConfig(unittest.TestCase): 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, env)) finally: |