test_lazy_import: add coverage for reload() and sys.modules deletion after reification
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report / test coverage gap
Lib/test/test_lazy_import/__init__.py has broad lazy import coverage, but it misses two practical state-transition scenarios after reification:
importlib.reload()on a module that was first imported lazily and then reified.- Deleting
sys.modules[name]after reification and then importing again.
Why this matters
These are common import-state operations and can regress subtly when lazy import behavior changes.
Adding tests helps lock in expected semantics and prevents regressions in future import machinery refactors.
Proposed change
Add two tests in test_lazy_import:
-
test_reload_after_lazy_reification_keeps_single_module_object- Reify a lazily imported module.
- Call
importlib.reload(). - Assert identity consistency between the binding and
sys.modules[name].
-
test_reimport_after_deleting_sys_modules_entry_creates_new_module- Reify a lazily imported module.
- Delete
sys.modules[name]. - Verify old binding still works.
- Re-import module and assert a new module object is cached.
Affected files
Lib/test/test_lazy_import/__init__.py
Version
- main (3.15 development branch)
Additional notes
This is test-only; no runtime behavior change is introduced.
Linked PRs
- gh-149014
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Lib/test/test_lazy_import/init.py から始めて、既存の lazy-import のカバレッジと関連するヘルパーを読みます。まず test_lazy_import テストを実行し、その後、再実体化後の reload() と sys.modules[name] を削除した後の再インポートのカバレッジを追加します。バインディングとキャッシュされたモジュールが指定された同一性の動作を維持し、削除されたエントリの再インポートによって新しいキャッシュ済みモジュールが作成されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- testing-qa
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 35/100