Skip to content

Commit

Permalink
GH-103224: Use the realpath of the Python executable in test_venv
Browse files Browse the repository at this point in the history
Now running tests through a Python symlink no longer causes `test_upgrade_dependencies` and `test_zippath_from_non_installed_posix` to fail.
  • Loading branch information
artemmukhin committed Apr 4, 2023
1 parent 32937d6 commit 67576f5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ def test_prompt(self):
def test_upgrade_dependencies(self):
builder = venv.EnvBuilder()
bin_path = 'Scripts' if sys.platform == 'win32' else 'bin'
python_exe = os.path.split(sys.executable)[1]
python_exe_realpath = os.path.realpath(sys.executable)
python_exe = os.path.split(python_exe_realpath)[1]
with tempfile.TemporaryDirectory() as fake_env_dir:
expect_exe = os.path.normcase(
os.path.join(fake_env_dir, bin_path, python_exe)
Expand Down Expand Up @@ -552,7 +553,8 @@ def test_zippath_from_non_installed_posix(self):
self.addCleanup(rmtree, non_installed_dir)
bindir = os.path.join(non_installed_dir, self.bindir)
os.mkdir(bindir)
shutil.copy2(sys.executable, bindir)
python_exe_realpath = os.path.realpath(sys.executable)
shutil.copy2(python_exe_realpath, bindir)
libdir = os.path.join(non_installed_dir, platlibdir, self.lib[1])
os.makedirs(libdir)
landmark = os.path.join(libdir, "os.py")
Expand Down Expand Up @@ -596,7 +598,7 @@ def test_zippath_from_non_installed_posix(self):
# libpython.so
ld_library_path = sysconfig.get_config_var("LIBDIR")
if not ld_library_path or sysconfig.is_python_build():
ld_library_path = os.path.abspath(os.path.dirname(sys.executable))
ld_library_path = os.path.abspath(os.path.dirname(python_exe_realpath))
if sys.platform == 'darwin':
ld_library_path_env = "DYLD_LIBRARY_PATH"
else:
Expand Down

0 comments on commit 67576f5

Please sign in to comment.