https://github.com/python/cpython/commit/6d5be4b1d6ca91a18e76ae8dad2c5e94837d6309
commit: 6d5be4b1d6ca91a18e76ae8dad2c5e94837d6309
branch: main
author: sobolevn <[email protected]>
committer: sobolevn <[email protected]>
date: 2026-05-18T21:55:27+03:00
summary:
gh-149977: Fix extra output of `-m test test_lazy_import` (#149978)
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 5d770eeae07a15..bcbf1a23233ba8 100644
--- a/Lib/test/test_lazy_import/__init__.py
+++ b/Lib/test/test_lazy_import/__init__.py
@@ -10,6 +10,7 @@
import unittest
import tempfile
import os
+import contextlib
from test import support
from test.support.script_helper import assert_python_ok
@@ -441,10 +442,14 @@ def tearDown(self):
def test_lazy_import_pkg(self):
"""lazy import of package submodule should load the package."""
- 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
self.assertIn("test.test_lazy_import.data.pkg", sys.modules)
self.assertIn("test.test_lazy_import.data.pkg.bar", sys.modules)
+ 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]