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 @@ -277,6 +277,22 @@ def test_lazy_import_type_attributes_accessible(self):
277277 proc = assert_python_ok ("-c" , code )
278278 self .assertIn (b"<built-in method resolve of lazy_import object at" , proc .out )
279279
280+ @support .requires_subprocess ()
281+ def test_lazy_import_type_attribute_error_message (self ):
282+ """Check that LazyImportType attribute error message is helpful."""
283+ code = textwrap .dedent (f"""
284+ lazy import asyncio
285+ try:
286+ globals()["asyncio"].Task
287+ except AttributeError as exc:
288+ assert str(exc) == (
289+ "cannot access attribute 'Task' "
290+ "on unresolved lazy import 'asyncio'"
291+ ), repr(str(exc))
292+ else:
293+ assert False, 'AttributeError is not raised'
294+ """ )
295+ assert_python_ok ("-c" , code )
280296
281297class SyntaxRestrictionTests (LazyImportTestCase ):
282298 """Tests for syntax restrictions on lazy imports."""
You can’t perform that action at this time.
0 commit comments