Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Lib/test/test_lazy_import/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."""
Expand Down
Loading