Skip to content

Commit 1e564ca

Browse files
committed
test_venv uses sysconfig._get_implementation().lower()
instead of hard-coded "python"
1 parent e46f28c commit 1e564ca

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Lib/test/test_venv.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
except ImportError:
3535
ctypes = None
3636

37+
# Implementation name for lib directory (e.g., 'python' for CPython, 'pypy' for PyPy)
38+
IMPL_NAME = sysconfig._get_implementation().lower()
39+
3740
# Platforms that set sys._base_executable can create venvs from within
3841
# another venv, so no need to skip tests that require venv.create().
3942
requireVenvCreate = unittest.skipUnless(
@@ -75,7 +78,7 @@ def setUp(self):
7578
self.include = 'Include'
7679
else:
7780
self.bindir = 'bin'
78-
self.lib = ('lib', f'python{sysconfig._get_python_version_abi()}')
81+
self.lib = ('lib', f'{IMPL_NAME}{sysconfig._get_python_version_abi()}')
7982
self.include = 'include'
8083
executable = sys._base_executable
8184
self.exe = os.path.split(executable)[-1]
@@ -357,8 +360,8 @@ def test_sysconfig_symlinks(self):
357360
('bin',),
358361
('include',),
359362
('lib',),
360-
('lib', 'python%d.%d' % sys.version_info[:2]),
361-
('lib', 'python%d.%d' % sys.version_info[:2], 'site-packages'),
363+
('lib', '%s%d.%d' % (IMPL_NAME, *sys.version_info[:2])),
364+
('lib', '%s%d.%d' % (IMPL_NAME, *sys.version_info[:2]), 'site-packages'),
362365
)
363366

364367
def create_contents(self, paths, filename):
@@ -688,7 +691,7 @@ def test_zippath_from_non_installed_posix(self):
688691
os.makedirs(libdir)
689692
landmark = os.path.join(libdir, "os.py")
690693
abi_thread = "t" if sysconfig.get_config_var("Py_GIL_DISABLED") else ""
691-
stdlib_zip = f"python{sys.version_info.major}{sys.version_info.minor}{abi_thread}"
694+
stdlib_zip = f"{IMPL_NAME}{sys.version_info.major}{sys.version_info.minor}{abi_thread}"
692695
zip_landmark = os.path.join(non_installed_dir,
693696
platlibdir,
694697
stdlib_zip)

0 commit comments

Comments
 (0)