Skip to content

Commit 94363ae

Browse files
Add test for non-module-level eager import
1 parent 6ca5cdb commit 94363ae

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_lazy_import/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,13 @@ def test_normal_import_dis(self):
19481948
else:
19491949
self.assertFail("IMPORT_NAME not found")
19501950

1951+
def test_eager_import_dis(self):
1952+
"""non module level import should show eager"""
1953+
code = compile("def f(): import foo", "exec", "exec")
1954+
f = io.StringIO()
1955+
dis.dis(code, file=f)
1956+
self.assertIn("foo + eager", f.getvalue())
1957+
19511958

19521959
@unittest.skipIf(_testcapi is None, 'need the _testcapi module')
19531960
class LazyCApiTests(unittest.TestCase):

0 commit comments

Comments
 (0)