Skip to content

[3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952)#152744

Merged
gpshead merged 1 commit into
python:3.14from
gpshead:backport-564c58c-3.14
Jul 1, 2026
Merged

[3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952)#152744
gpshead merged 1 commit into
python:3.14from
gpshead:backport-564c58c-3.14

Conversation

@gpshead

@gpshead gpshead commented Jul 1, 2026

Copy link
Copy Markdown
Member

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)

Co-authored-by: Jiucheng(Oliver) git.jiucheng@gmail.com


Manual backport notes (3.14)

miss-islington could not cleanly backport this to 3.14 due to a conflict in Lib/test/test_inspect/test_inspect.py. The 3.14 branch predates the python -m inspect --details CLI test refactor that exists on main/3.15 (it still has the simpler TestMain.test_details rather than TestModuleCLI with the test_details_option_with_*/test_get_cli_details_for_* suite).

The fix was translated to 3.14's dialect:

  • The _expected_cached() helper was added verbatim from the original PR, in TestMain.
  • It was applied to the single TestMain.test_details, replacing the environment-dependent module.__spec__.cached check. The redundant self.assertIn(module.__cached__, output) line (same pyc path, and itself failing under PYTHONPYCACHEPREFIX) was dropped.
  • None of the main-only test machinery was pulled in.

The other four files and the NEWS entry cherry-picked cleanly (identical hunks to the original).

Verified: test_inspect, test_compileall, test_import, test_importlib, and test_py_compile all pass both normally and with PYTHONPYCACHEPREFIX set; make patchcheck is clean.

…is set (pythonGH-151952)

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
@gpshead gpshead self-assigned this Jul 1, 2026
@gpshead gpshead added the needs backport to 3.13 bugs and security fixes label Jul 1, 2026
@gpshead gpshead marked this pull request as ready for review July 1, 2026 07:53
@gpshead gpshead merged commit 7087839 into python:3.14 Jul 1, 2026
51 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jul 1, 2026

Copy link
Copy Markdown

GH-152748 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jul 1, 2026
gpshead added a commit that referenced this pull request Jul 1, 2026
…GH-151952) (GH-152744) (#152748)

[3.14] gh-151626: Fix tests that fail when PYTHONPYCACHEPREFIX is set (GH-151952) (GH-152744)

Fix tests in test_compileall, test_import, test_importlib, test_py_compile, and test_inspect to neutralize PYTHONPYCACHEPREFIX
(cherry picked from commit 564c58c)
(cherry picked from commit 7087839)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants