]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44860: Update test_sysconfig for posix_user platlib (GH-28235)
authorVictor Stinner <vstinner@python.org>
Thu, 9 Sep 2021 09:02:48 +0000 (11:02 +0200)
committerGitHub <noreply@github.com>
Thu, 9 Sep 2021 09:02:48 +0000 (11:02 +0200)
Update test_sysconfig.test_user_similar() for the posix_user scheme:
"platlib" doesn't use sys.platlibdir.

Lib/test/pythoninfo.py
Lib/test/test_sysconfig.py
Misc/NEWS.d/next/Tests/2021-09-08-13-01-37.bpo-44860.qXd0kx.rst [new file with mode: 0644]

index 278dfe7f7da7acf7fd225b53911d0759f27f5921..39ee9e1d769f8d24cd1cb6d79008b67580304723 100644 (file)
@@ -96,6 +96,7 @@ def collect_sys(info_add):
         'maxunicode',
         'path',
         'platform',
+        'platlibdir',
         'prefix',
         'thread_info',
         'version',
index b8b9add36d766562701cfc424bc4dbbc34855a14..9408657c9188630f30eb24e9dfa42870d0dd14b3 100644 (file)
@@ -296,7 +296,17 @@ class TestSysConfig(unittest.TestCase):
                 base = base.replace(sys.base_prefix, sys.prefix)
             if HAS_USER_BASE:
                 user_path = get_path(name, 'posix_user')
-                self.assertEqual(user_path, global_path.replace(base, user, 1))
+                expected = global_path.replace(base, user, 1)
+                # bpo-44860: platlib of posix_user doesn't use sys.platlibdir,
+                # whereas posix_prefix does.
+                if name == 'platlib':
+                    # Replace "/lib64/python3.11/site-packages" suffix
+                    # with "/lib/python3.11/site-packages".
+                    py_version_short = sysconfig.get_python_version()
+                    suffix = f'python{py_version_short}/site-packages'
+                    expected = expected.replace(f'/{sys.platlibdir}/{suffix}',
+                                                f'/lib/{suffix}')
+                self.assertEqual(user_path, expected)
 
     def test_main(self):
         # just making sure _main() runs and returns things in the stdout
diff --git a/Misc/NEWS.d/next/Tests/2021-09-08-13-01-37.bpo-44860.qXd0kx.rst b/Misc/NEWS.d/next/Tests/2021-09-08-13-01-37.bpo-44860.qXd0kx.rst
new file mode 100644 (file)
index 0000000..153a9c5
--- /dev/null
@@ -0,0 +1,2 @@
+Update ``test_sysconfig.test_user_similar()`` for the posix_user scheme:
+``platlib`` doesn't use :data:`sys.platlibdir`. Patch by Victor Stinner.