Skip to content

Commit 25bb266

Browse files
authored
gh-109748: Fix venv test_zippath_from_non_installed_posix() (#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.
1 parent d73c12b commit 25bb266

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
@@ -559,6 +559,13 @@ def test_zippath_from_non_installed_posix(self):
559559
platlibdir,
560560
stdlib_zip)
561561
additional_pythonpath_for_non_installed = []
562+
563+
# gh-109748: Don't copy __pycache__/ sub-directories, because they can
564+
# be modified by other Python tests running in parallel.
565+
ignored_names = {'__pycache__'}
566+
def ignore_pycache(src, names):
567+
return ignored_names
568+
562569
# Copy stdlib files to the non-installed python so venv can
563570
# correctly calculate the prefix.
564571
for eachpath in sys.path:
@@ -575,7 +582,8 @@ def test_zippath_from_non_installed_posix(self):
575582
if os.path.isfile(fn):
576583
shutil.copy(fn, libdir)
577584
elif os.path.isdir(fn):
578-
shutil.copytree(fn, os.path.join(libdir, name))
585+
shutil.copytree(fn, os.path.join(libdir, name),
586+
ignore=ignore_pycache)
579587
else:
580588
additional_pythonpath_for_non_installed.append(
581589
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)