https://github.com/python/cpython/commit/83197a53612920fa52883b31700ae4d1eed255d5 commit: 83197a53612920fa52883b31700ae4d1eed255d5 branch: 3.14 author: Miss Islington (bot) <[email protected]> committer: JelleZijlstra <[email protected]> date: 2026-08-13T14:41:45Z summary:
[3.14] gh-141174: Test re-stringifying a `ForwardRef` (GH-155689) (#155708) Test that re-evaluating a `ForwardRef` with `STRING` format uses the cache (cherry picked from commit 5dab4902dd24a692b9f9c0cea1cad14c429307c2) Co-authored-by: dr-carlos <[email protected]> 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]
