https://github.com/python/cpython/commit/9b4090c48e0b5e51f15ca0c52f7c173de71e3ba6
commit: 9b4090c48e0b5e51f15ca0c52f7c173de71e3ba6
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-06-05T15:21:10Z
summary:
gh-149977: Fix extra output of `-m test test_lazy_import`, again (#150965)
files:
M Lib/test/test_lazy_import/__init__.py
diff --git a/Lib/test/test_lazy_import/__init__.py
b/Lib/test/test_lazy_import/__init__.py
index 94576a206b42ca..1724beb8ce6951 100644
--- a/Lib/test/test_lazy_import/__init__.py
+++ b/Lib/test/test_lazy_import/__init__.py
@@ -447,11 +447,15 @@ def test_lazy_import_pkg(self):
def test_lazy_submodule_stored_in_parent_dict(self):
"""Accessing a lazy submodule should store it in the parent's
__dict__."""
- import test.test_lazy_import.data.lazy_import_pkg
+ out = io.StringIO()
+
+ with contextlib.redirect_stdout(out):
+ import test.test_lazy_import.data.lazy_import_pkg
pkg = sys.modules["test.test_lazy_import.data.pkg"]
self.assertIn("bar", pkg.__dict__)
self.assertIs(pkg.__dict__["bar"],
sys.modules["test.test_lazy_import.data.pkg.bar"])
+ self.assertIn("BAR_MODULE_LOADED", out.getvalue())
def test_lazy_import_pkg_cross_import(self):
"""Cross-imports within package should preserve lazy imports."""
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]