8000 GH-103224: Use the realpath of the Python executable in `test_venv` · python/cpython@67576f5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 67576f5

Browse files
committed
GH-103224: Use the realpath of the Python executable in test_venv
Now running tests through a Python symlink no longer causes `test_upgrade_dependencies` and `test_zippath_from_non_installed_posix` to fail.
1 parent 32937d6 commit 67576f5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Lib/test/test_venv.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def test_prompt(self):
208208
def test_upgrade_dependencies(self):
209209
builder = venv.EnvBuilder()
210210
bin_path = 'Scripts' if sys.platform == 'win32' else 'bin'
211-
python_exe = os.path.split(sys.executable)[1]
211+
python_exe_realpath = os.path.realpath(sys.executable)
212+
python_exe = os.path.split(python_exe_realpath)[1]
212213
with tempfile.TemporaryDirectory() as fake_env_dir:
213214
expect_exe = os.path.normcase(
214215
os.path.join(fake_env_dir, bin_path, python_exe)
@@ -552,7 +553,8 @@ def test_zippath_from_non_installed_posix(self):
552553
self.addCleanup(rmtree, non_installed_dir)
553554
bindir = os.path.join(non_installed_dir, self.bindir)
554555
os.mkdir(bindir)
555-
shutil.copy2(sys.executable, bindir)
556+
python_exe_realpath = os.path.realpath(sys.executable)
557+
shutil.copy2(python_exe_realpath, bindir)
556558
libdir = os.path.join(non_installed_dir, platlibdir, self.lib[1])
557559
os.makedirs(libdir)
558560
landmark = os.path.join(libdir, "os.py")
@@ -596,7 +598,7 @@ def test_zippath_from_non_installed_posix(self):
596598
# libpython.so
597599
ld_library_path = sysconfig.get_config_var("LIBDIR")
598600
if not ld_library_path or sysconfig.is_python_build():
599-
ld_library_path = os.path.abspath(os.path.dirname(sys.executable))
601+
ld_library_path = os.path.abspath(os.path.dirname(python_exe_realpath))
600602
if sys.platform == 'darwin':
601603
ld_library_path_env = "DYLD_LIBRARY_PATH"
602604
else:

0 commit comments

Comments
 (0)
0