diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py index 5087c3ca425f1f..5bfcf5ce4131e3 100644 --- a/Lib/test/test_annotationlib.py +++ b/Lib/test/test_annotationlib.py @@ -2133,8 +2133,13 @@ def f(a: unknown | str | int | list[str] | tuple[int, ...]): ... self.assertIsNone(fr.__resolved_str_cache__) self.assertEqual(fr.evaluate(format=Format.STRING), "unknown | str | int | list[str] | tuple[int, ...]") + + # Test that the cache is now set correctly self.assertEqual(fr.__resolved_str_cache__, "unknown | str | int | list[str] | tuple[int, ...]") + # Test that future evaluations return the same cache + self.assertIs(fr.evaluate(format=Format.STRING), fr.__resolved_str_cache__) + def test_evaluate_forwardref_format(self): fr = ForwardRef("undef") evaluated = fr.evaluate(format=Format.FORWARDREF)