https://github.com/python/cpython/commit/060c3edc4bcdc6873676f4b2153e6122f9f085bf
commit: 060c3edc4bcdc6873676f4b2153e6122f9f085bf
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2024-02-07T11:36:10+02:00
summary:

[3.12] gh-103224: Resolve paths properly in test_sysconfig (GH-103292) 
(GH-115100)

To pass tests when executed through a Python symlink.

(cherry picked from commit 71239d50b54c90afd3fdde260848e0c6d73a5c27)

Co-authored-by: Artem Mukhin <[email protected]>
Co-authored-by: Miro HronĨok <[email protected]>

files:
M Lib/test/test_sysconfig.py

diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index b6dbf3d52cb4c3..1137c2032b91af 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -149,17 +149,21 @@ def test_posix_venv_scheme(self):
                                'python%d.%d' % sys.version_info[:2],
                                'site-packages')
 
-        # Resolve the paths in prefix
-        binpath = os.path.join(sys.prefix, binpath)
-        incpath = os.path.join(sys.prefix, incpath)
-        libpath = os.path.join(sys.prefix, libpath)
+        # Resolve the paths in an imaginary venv/ directory
+        binpath = os.path.join('venv', binpath)
+        incpath = os.path.join('venv', incpath)
+        libpath = os.path.join('venv', libpath)
 
-        self.assertEqual(binpath, sysconfig.get_path('scripts', 
scheme='posix_venv'))
-        self.assertEqual(libpath, sysconfig.get_path('purelib', 
scheme='posix_venv'))
+        # Mimic the venv module, set all bases to the venv directory
+        bases = ('base', 'platbase', 'installed_base', 'installed_platbase')
+        vars = {base: 'venv' for base in bases}
+
+        self.assertEqual(binpath, sysconfig.get_path('scripts', 
scheme='posix_venv', vars=vars))
+        self.assertEqual(libpath, sysconfig.get_path('purelib', 
scheme='posix_venv', vars=vars))
 
         # The include directory on POSIX isn't exactly the same as before,
         # but it is "within"
-        sysconfig_includedir = sysconfig.get_path('include', 
scheme='posix_venv')
+        sysconfig_includedir = sysconfig.get_path('include', 
scheme='posix_venv', vars=vars)
         self.assertTrue(sysconfig_includedir.startswith(incpath + os.sep))
 
     def test_nt_venv_scheme(self):
@@ -169,14 +173,19 @@ def test_nt_venv_scheme(self):
         incpath = 'Include'
         libpath = os.path.join('Lib', 'site-packages')
 
-        # Resolve the paths in prefix
-        binpath = os.path.join(sys.prefix, binpath)
-        incpath = os.path.join(sys.prefix, incpath)
-        libpath = os.path.join(sys.prefix, libpath)
+        # Resolve the paths in an imaginary venv\ directory
+        venv = 'venv'
+        binpath = os.path.join(venv, binpath)
+        incpath = os.path.join(venv, incpath)
+        libpath = os.path.join(venv, libpath)
+
+        # Mimic the venv module, set all bases to the venv directory
+        bases = ('base', 'platbase', 'installed_base', 'installed_platbase')
+        vars = {base: 'venv' for base in bases}
 
-        self.assertEqual(binpath, sysconfig.get_path('scripts', 
scheme='nt_venv'))
-        self.assertEqual(incpath, sysconfig.get_path('include', 
scheme='nt_venv'))
-        self.assertEqual(libpath, sysconfig.get_path('purelib', 
scheme='nt_venv'))
+        self.assertEqual(binpath, sysconfig.get_path('scripts', 
scheme='nt_venv', vars=vars))
+        self.assertEqual(incpath, sysconfig.get_path('include', 
scheme='nt_venv', vars=vars))
+        self.assertEqual(libpath, sysconfig.get_path('purelib', 
scheme='nt_venv', vars=vars))
 
     def test_venv_scheme(self):
         if sys.platform == 'win32':

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to