From: sobolevn Date: Fri, 5 Jun 2026 15:21:10 +0000 (+0300) Subject: gh-149977: Fix extra output of `-m test test_lazy_import`, again (#150965) X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=9b4090c48e0b5e51f15ca0c52f7c173de71e3ba6;p=thirdparty%2FPython%2Fcpython.git gh-149977: Fix extra output of `-m test test_lazy_import`, again (#150965) --- diff --git a/Lib/test/test_lazy_import/__init__.py b/Lib/test/test_lazy_import/__init__.py index 94576a206b42..1724beb8ce69 100644 --- a/Lib/test/test_lazy_import/__init__.py +++ b/Lib/test/test_lazy_import/__init__.py @@ -447,11 +447,15 @@ class PackageTests(LazyImportTestCase): 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."""