gh-141174: Test re-stringifying a `ForwardRef` (#155689)
JelleZijlstra <[email protected]> Thu, 13 Aug 2026 10:14:58 -0400 (EDT)
| Newsgroups | gmane.comp.python.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/python/cpython/commit/5dab4902dd24a692b9f9c0cea1cad14c429307c2 commit: 5dab4902dd24a692b9f9c0cea1cad14c429307c2 branch: main author: dr-carlos <[email protected]> committer: JelleZijlstra <[email protected]> date: 2026-08-13T14:14:33Z summary: gh-141174: Test re-stringifying a `ForwardRef` (#155689) Test that re-evaluating a `ForwardRef` with `STRING` format uses the cache files: M Lib/test/test_annotationlib.py 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) _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]