Skip to content

🧪 test(discovery): fix test_py_info_cache_clear outside venv#3065

Merged
gaborbernat merged 3 commits into
pypa:mainfrom
gaborbernat:fix/test-py-info-cache-clear
Feb 23, 2026
Merged

🧪 test(discovery): fix test_py_info_cache_clear outside venv#3065
gaborbernat merged 3 commits into
pypa:mainfrom
gaborbernat:fix/test-py-info-cache-clear

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

test_py_info_cache_clear fails when tests run outside a virtual environment (e.g. Fedora RPM
builds, reported in #2939). The test tracked cumulative _run_subprocess spy counts across two
from_exe calls and assumed a 2 * count relationship, which breaks when _resolve_to_system
doesn't trigger additional subprocess calls — the case when system_executable == executable.

Restructured to follow the same pattern as the already-fixed sibling
test_py_info_cache_invalidation_on_py_info_change: set up the spy only after clearing the cache,
and account for the venv vs non-venv difference using native_difference. This makes the assertion
independent of how many subprocess calls the initial cache-warming from_exe triggers. 🐛

Fixes #2939

The tox.ini to tox.toml migration in pypa#3050 didn't update the sdist
include list, so tox.toml was missing from published packages.

Fixes pypa#3060
The test assumed a fixed relationship between _run_subprocess call
counts across both from_exe invocations, which breaks when running
outside a virtual environment (e.g. Fedora RPM builds) where
_resolve_to_system doesn't trigger additional subprocess calls.

Restructured to match the pattern used in the already-fixed sibling
test_py_info_cache_invalidation_on_py_info_change: set up the spy
after cache clearing, and account for the venv vs non-venv difference
using native_difference.

Fixes pypa#2939
@gaborbernat gaborbernat force-pushed the fix/test-py-info-cache-clear branch from 0456359 to 6876203 Compare February 23, 2026 13:33
@gaborbernat gaborbernat enabled auto-merge (squash) February 23, 2026 13:50
@gaborbernat gaborbernat merged commit f8f7f48 into pypa:main Feb 23, 2026
56 checks passed
This was referenced Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure of test_py_info_cache_invalidation_on_py_info_change

1 participant