bpo-45337: Use the realpath of the new executable when creating a venv on Windows (GH-28663)
(cherry picked from commit 6811fdaec825bd6ab64e358a4b480108f5634d2d)
Co-authored-by: Steve Dower <steve.dower@python.org>
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 098ba17..94d6265 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -150,14 +150,20 @@ def test_prompt(self):
def test_upgrade_dependencies(self):
builder = venv.EnvBuilder()
bin_path = 'Scripts' if sys.platform == 'win32' else 'bin'
- python_exe = 'python.exe' if sys.platform == 'win32' else 'python'
+ python_exe = os.path.split(sys.executable)[1]
with tempfile.TemporaryDirectory() as fake_env_dir:
+ expect_exe = os.path.normcase(
+ os.path.join(fake_env_dir, bin_path, python_exe)
+ )
+ if sys.platform == 'win32':
+ expect_exe = os.path.normcase(os.path.realpath(expect_exe))
def pip_cmd_checker(cmd):
+ cmd[0] = os.path.normcase(cmd[0])
self.assertEqual(
cmd,
[
- os.path.join(fake_env_dir, bin_path, python_exe),
+ expect_exe,
'-m',
'pip',
'install',