Skip to content

Commit 358282e

Browse files
[3.11] gh-109748: Fix venv test_zippath_from_non_installed_posix() (GH-109872) (#109874)
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 25bb266) Co-authored-by: Victor Stinner <[email protected]>
1 parent 22a8efa commit 358282e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Lib/test/test_venv.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,13 @@ def test_zippath_from_non_installed_posix(self):
562562
platlibdir,
563563
stdlib_zip)
564564
additional_pythonpath_for_non_installed = []
565+
566+
# gh-109748: Don't copy __pycache__/ sub-directories, because they can
567+
# be modified by other Python tests running in parallel.
568+
ignored_names = {'__pycache__'}
569+
def ignore_pycache(src, names):
570+
return ignored_names
571+
565572
# Copy stdlib files to the non-installed python so venv can
566573
# correctly calculate the prefix.
567574
for eachpath in sys.path:
@@ -578,7 +585,8 @@ def test_zippath_from_non_installed_posix(self):
578585
if os.path.isfile(fn):
579586
shutil.copy(fn, libdir)
580587
elif os.path.isdir(fn):
581-
shutil.copytree(fn, os.path.join(libdir, name))
588+
shutil.copytree(fn, os.path.join(libdir, name),
589+
ignore=ignore_pycache)
582590
else:
583591
additional_pythonpath_for_non_installed.append(
584592
eachpath)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix ``test_zippath_from_non_installed_posix()`` of test_venv: don't copy
2+
``__pycache__/`` sub-directories, because they can be modified by other Python
3+
tests running in parallel. Patch by Victor Stinner.

0 commit comments

Comments
 (0)