diff --git a/Lib/test/lazy_imports_all_exclude.txt b/Lib/test/lazy_imports_all_exclude.txt index f85ea5e4f301c0..00b883590d5d65 100644 --- a/Lib/test/lazy_imports_all_exclude.txt +++ b/Lib/test/lazy_imports_all_exclude.txt @@ -28,5 +28,4 @@ test_profiling test_pyrepl test_subprocess test_symtable -test_type_annotations test_unittest diff --git a/Lib/test/test_type_annotations.py b/Lib/test/test_type_annotations.py index 02f3e8b9caddb4..11bcec5f562a42 100644 --- a/Lib/test/test_type_annotations.py +++ b/Lib/test/test_type_annotations.py @@ -4,6 +4,7 @@ import textwrap import types import unittest +import sys from test.support import run_code, check_syntax_error, import_helper, cpython_only from test.test_inspect import inspect_stringized_annotations @@ -162,7 +163,11 @@ def test_partially_executed_module(self): partialexe.a.__annotations__, {"v1": int, "v2": int}, ) - self.assertEqual(partialexe.b.annos, {"v1": int}) + # Module execution semantics differ based on the lazy imports mode: + if sys.get_lazy_imports() == "all": + self.assertEqual(partialexe.b.annos, {"v1": int, "v2": int}) # full + else: + self.assertEqual(partialexe.b.annos, {"v1": int}) # partial @cpython_only def test_no_cell(self):