MCPcopy Index your code
hub / github.com/python/cpython / test_forwardref_partial_evaluation

Method test_forwardref_partial_evaluation

Lib/test/test_typing.py:10031–10042  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

10029 self.assertIs(type(field_c3.__metadata__[0]), bool)
10030
10031 def test_forwardref_partial_evaluation(self):
10032 # Test that Annotated partially evaluates if it contains a ForwardRef
10033 # See: https://github.com/python/cpython/issues/137706
10034 def f(x: Annotated[undefined, '']): pass
10035
10036 ann = annotationlib.get_annotations(f, format=annotationlib.Format.FORWARDREF)
10037
10038 # Test that the attributes are retrievable from the partially evaluated annotation
10039 x_ann = ann['x']
10040 self.assertIs(get_origin(x_ann), Annotated)
10041 self.assertEqual(x_ann.__origin__, EqualToForwardRef('undefined', owner=f))
10042 self.assertEqual(x_ann.__metadata__, ('',))
10043
10044
10045class TypeAliasTests(BaseTestCase):

Callers

nothing calls this directly

Calls 4

get_originFunction · 0.90
EqualToForwardRefClass · 0.90
assertIsMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected