Skip to content

Commit 6bf6716

Browse files
committed
Fix test for pip 26.1 uninstall behavior
pip 26.1 (pypa/pip#13725) tracks the entire __pycache__ directory for removal instead of individual .pyc files, which breaks pip's empty parent directory cleanup. Empty leftover dirs (pip/, _distutils_hack/) now remain after uninstall. Filter empty directory trees out of the post-uninstall assertion.
1 parent e32aedf commit 6bf6716

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

File renamed without changes.

tests/unit/seed/embed/test_bootstrap_link_via_app_data.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,12 @@ def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies,
122122
purelib = result.creator.purelib
123123
patch_files = {purelib / f"{'_virtualenv'}.{i}" for i in ("py", "pyc", "pth")}
124124
patch_files.add(purelib / "__pycache__")
125-
post_run = set(site_package.iterdir()) - patch_files
125+
126+
# pip 26.1+ leaves empty parent directories on uninstall (pypa/pip#13725)
127+
def _has_files(path: Path) -> bool:
128+
return path.is_file() or (path.is_dir() and any(_has_files(child) for child in path.iterdir()))
129+
130+
post_run = {p for p in set(site_package.iterdir()) - patch_files if _has_files(p)}
126131
assert not post_run, "\n".join(str(i) for i in post_run)
127132

128133

0 commit comments

Comments
 (0)