]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-109748: Fix venv test_zippath_from_non_installed_posix() (GH-109872) (...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 25 Sep 2023 23:41:32 +0000 (16:41 -0700)
committerGitHub <noreply@github.com>
Mon, 25 Sep 2023 23:41:32 +0000 (01:41 +0200)
gh-109748: Fix venv test_zippath_from_non_installed_posix() (GH-109872)

Fix test_zippath_from_non_installed_posix() of test_venv: don't copy
__pycache__/ sub-directories, because they can be modified by other
Python tests running in parallel.
(cherry picked from commit 25bb266fc876b344e31e0b5634a4db94912c1aba)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_venv.py
Misc/NEWS.d/next/Tests/2023-09-26-00-49-18.gh-issue-109748.nxlT1i.rst [new file with mode: 0644]

index c7efff549b86315b2be9f5eea59fb8fb54d71324..a37c6b7163f2d288bd3dd3287b5b5a70b892ca23 100644 (file)
@@ -562,6 +562,13 @@ class BasicTest(BaseTest):
                                     platlibdir,
                                     stdlib_zip)
         additional_pythonpath_for_non_installed = []
+
+        # gh-109748: Don't copy __pycache__/ sub-directories, because they can
+        # be modified by other Python tests running in parallel.
+        ignored_names = {'__pycache__'}
+        def ignore_pycache(src, names):
+            return ignored_names
+
         # Copy stdlib files to the non-installed python so venv can
         # correctly calculate the prefix.
         for eachpath in sys.path:
@@ -578,7 +585,8 @@ class BasicTest(BaseTest):
                     if os.path.isfile(fn):
                         shutil.copy(fn, libdir)
                     elif os.path.isdir(fn):
-                        shutil.copytree(fn, os.path.join(libdir, name))
+                        shutil.copytree(fn, os.path.join(libdir, name),
+                                        ignore=ignore_pycache)
             else:
                 additional_pythonpath_for_non_installed.append(
                     eachpath)
diff --git a/Misc/NEWS.d/next/Tests/2023-09-26-00-49-18.gh-issue-109748.nxlT1i.rst b/Misc/NEWS.d/next/Tests/2023-09-26-00-49-18.gh-issue-109748.nxlT1i.rst
new file mode 100644 (file)
index 0000000..840366b
--- /dev/null
@@ -0,0 +1,3 @@
+Fix ``test_zippath_from_non_installed_posix()`` of test_venv: don't copy
+``__pycache__/`` sub-directories, because they can be modified by other Python
+tests running in parallel. Patch by Victor Stinner.