Skip to content

gh-149013: extend test_lazy_import coverage for reload() and sys.modu…#149014

Open
XiaoWan-zi wants to merge 4 commits into
python:mainfrom
XiaoWan-zi:add_two_tests_to_lazy_import
Open

gh-149013: extend test_lazy_import coverage for reload() and sys.modu…#149014
XiaoWan-zi wants to merge 4 commits into
python:mainfrom
XiaoWan-zi:add_two_tests_to_lazy_import

Conversation

@XiaoWan-zi
Copy link
Copy Markdown
Contributor

@XiaoWan-zi XiaoWan-zi commented Apr 26, 2026

Summary

Add two tests to test_lazy_import covering post-reification import state transitions:

  • test_reload_after_lazy_reification_keeps_single_module_object
  • test_reimport_after_deleting_sys_modules_entry_creates_new_module

Details

  • Verify importlib.reload() behavior after lazy reification.
  • Verify behavior after removing sys.modules["json"]:
    • existing binding remains usable,
    • a later explicit import creates and caches a new module object.

Files

  • Lib/test/test_lazy_import/__init__.py

Test

  • ./python -m test test_lazy_import

Notes

Test-only change; no interpreter behavior changes.

Comment thread Lib/test/test_lazy_import/__init__.py Outdated
@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 18, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Use lazy from json import ... instead of lazy import json so reload
tests cover fresh bindings after reification, per review feedback.
@XiaoWan-zi
Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again.

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented May 19, 2026

Thanks for making the requested changes!

@DinoV: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from DinoV May 19, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants