Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JelleZijlstra committed Sep 26, 2024
1 parent 26f1c7c commit 2012bb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Lib/annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ def get_annotations(
# But if we didn't get it, we use __annotations__ instead.
ann = _get_dunder_annotations(obj)
return ann
case Format.VALUE_WITH_FAKE_GLOBALS:
raise ValueError("The VALUE_WITH_FAKE_GLOBALS format is for internal use only")
case _:
raise ValueError(f"Unsupported format {format!r}")

Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_annotationlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ def foo(a: int, b: str):

foo.__annotations__ = {"a": "foo", "b": "str"}
for format in annotationlib.Format:
if format is Format.VALUE_WITH_FAKE_GLOBALS:
continue
with self.subTest(format=format):
self.assertEqual(
annotationlib.get_annotations(foo, format=format),
Expand Down Expand Up @@ -778,6 +780,8 @@ def __annotations__(self):

wa = WeirdAnnotations()
for format in Format:
if format is Format.VALUE_WITH_FAKE_GLOBALS:
continue
with (
self.subTest(format=format),
self.assertRaisesRegex(
Expand Down

0 comments on commit 2012bb4

Please sign in to comment.