Skip to content

PEP 810: Add comprehensive Lazy Import tests ported from Cinder test suite#149739

Draft
brittanyrey wants to merge 1 commit into
python:mainfrom
brittanyrey:add-lazy-import-tests
Draft

PEP 810: Add comprehensive Lazy Import tests ported from Cinder test suite#149739
brittanyrey wants to merge 1 commit into
python:mainfrom
brittanyrey:add-lazy-import-tests

Conversation

@brittanyrey
Copy link
Copy Markdown
Contributor

Port missing test coverage from the Cinder/MetaPython Lazy Imports test suite to CPython's test_lazy_import, covering behaviors not previously tested:

  • Dict operations with lazy values (copy, |, update, values/items)
  • from X import * resolution behavior with lazy imports
  • Submodule laziness (unused submodules stay lazy, side effects)
  • Attribute side effects (submodule imports don't overwrite parent attrs)
  • Module/variable name collisions (submodule vs variable ordering)
  • Deleted module reimport (sys.modules deletion and reimport)
  • Circular import resolution (lazy imports breaking circular deadlocks)
  • Custom __import__ via exec with lazy imports
  • Dict mutation during module loading
  • Runtime enable/disable of lazy imports via sys.set_lazy_imports()

Adds supporting test data modules.

Port missing test coverage from the internal lazy imports test suite to
cpython's test_lazy_import, covering behaviors not previously tested:

- Dict operations with lazy values (copy, |, update, values/items)
- from X import * resolution behavior with lazy imports
- Submodule laziness (unused submodules stay lazy, side effects)
- Attribute side effects (submodule imports don't overwrite parent attrs)
- Module/variable name collisions (submodule vs variable ordering)
- Deleted module reimport (sys.modules deletion and reimport)
- Circular import resolution (lazy imports breaking circular deadlocks)
- Custom __import__ via exec with lazy imports
- Dict mutation during module loading
- Runtime enable/disable of lazy imports via sys.set_lazy_imports()

Adds supporting test data modules: metasyntactic package hierarchy,
versioned package, module_same_name_var_order packages, circular_import_pkg,
and cycle_with_load_global_pkg.
@brittanyrey brittanyrey force-pushed the add-lazy-import-tests branch from 28ae182 to 15f157e Compare May 12, 2026 17:53
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.

1 participant