test_lazy_import: add coverage for reload() and sys.modules deletion after reification
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece em Lib/test/test_lazy_import/init.py e leia a cobertura existente de lazy-import e os helpers relacionados. Execute primeiro os testes test_lazy_import e, em seguida, adicione cobertura para reload() após a reificação e para a reimportação após excluir sys.modules[name]. A tarefa estará concluída quando o binding e o módulo em cache mantiverem o comportamento de identidade especificado, enquanto a reimportação após a exclusão da entrada criar um novo módulo em cache.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- testing-qa
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 35/100