https://github.com/python/cpython/commit/d0a263d6d6c94272249d76e139ce80f749103bfe
commit: d0a263d6d6c94272249d76e139ce80f749103bfe
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: pablogsal <[email protected]>
date: 2026-06-05T15:46:57Z
summary:

[3.15] gh-149977: Fix extra output of `-m test test_lazy_import`, again 
(GH-150965) (#150975)

gh-149977: Fix extra output of `-m test test_lazy_import`, again (GH-150965)
(cherry picked from commit 9b4090c48e0b5e51f15ca0c52f7c173de71e3ba6)

Co-authored-by: sobolevn <[email protected]>

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 2a82ac78fb90fb..aeb275b958ec5e 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]

Reply via email to