Skip to content

Commit 61fce18

Browse files
sobolevnmiss-islington
authored andcommitted
gh-149977: Fix extra output of -m test test_lazy_import, again (GH-150965)
(cherry picked from commit 9b4090c) Co-authored-by: sobolevn <mail@sobolevn.me>
1 parent 06ffcde commit 61fce18

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/test/test_lazy_import/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,15 @@ def test_lazy_import_pkg(self):
447447

448448
def test_lazy_submodule_stored_in_parent_dict(self):
449449
"""Accessing a lazy submodule should store it in the parent's __dict__."""
450-
import test.test_lazy_import.data.lazy_import_pkg
450+
out = io.StringIO()
451+
452+
with contextlib.redirect_stdout(out):
453+
import test.test_lazy_import.data.lazy_import_pkg
451454

452455
pkg = sys.modules["test.test_lazy_import.data.pkg"]
453456
self.assertIn("bar", pkg.__dict__)
454457
self.assertIs(pkg.__dict__["bar"], sys.modules["test.test_lazy_import.data.pkg.bar"])
458+
self.assertIn("BAR_MODULE_LOADED", out.getvalue())
455459

456460
def test_lazy_import_pkg_cross_import(self):
457461
"""Cross-imports within package should preserve lazy imports."""

0 commit comments

Comments
 (0)