Skip to content

Commit c16083b

Browse files
committed
Add standard method annotate function test
1 parent ea60223 commit c16083b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Lib/test/test_annotationlib.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,24 @@ def __call__(self, format, /, __Format=Format,
16131613

16141614
self.assertEqual(annotations, {"x": str})
16151615

1616+
def test_callable_method_annotate_forwardref_value_fallback(self):
1617+
# If Format.STRING and Format.VALUE_WITH_FAKE_GLOBALS are not
1618+
# supported fall back to Format.VALUE and convert to strings
1619+
class Annotate:
1620+
def format(self, format, /, __Format=Format,
1621+
__NotImplementedError=NotImplementedError):
1622+
if format == __Format.VALUE:
1623+
return {"x": str}
1624+
else:
1625+
raise __NotImplementedError(format)
1626+
1627+
annotations = annotationlib.call_annotate_function(
1628+
Annotate().format,
1629+
Format.FORWARDREF,
1630+
)
1631+
1632+
self.assertEqual(annotations, {"x": str})
1633+
16161634
def test_callable_classmethod_annotate_forwardref_value_fallback(self):
16171635
# If Format.STRING and Format.VALUE_WITH_FAKE_GLOBALS are not
16181636
# supported fall back to Format.VALUE and convert to strings

0 commit comments

Comments
 (0)