File tree Expand file tree Collapse file tree
Lib/test/test_lazy_import Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010import unittest
1111import tempfile
1212import os
13+ import contextlib
1314
1415from test import support
1516from test .support .script_helper import assert_python_ok
@@ -441,10 +442,14 @@ def tearDown(self):
441442
442443 def test_lazy_import_pkg (self ):
443444 """lazy import of package submodule should load the package."""
444- import test .test_lazy_import .data .lazy_import_pkg
445+ out = io .StringIO ()
446+
447+ with contextlib .redirect_stdout (out ):
448+ import test .test_lazy_import .data .lazy_import_pkg
445449
446450 self .assertIn ("test.test_lazy_import.data.pkg" , sys .modules )
447451 self .assertIn ("test.test_lazy_import.data.pkg.bar" , sys .modules )
452+ self .assertIn ("BAR_MODULE_LOADED" , out .getvalue ())
448453
449454 def test_lazy_import_pkg_cross_import (self ):
450455 """Cross-imports within package should preserve lazy imports."""
You can’t perform that action at this time.
0 commit comments