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

Method test_function

Lib/test/test_annotationlib.py:102–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

100 self.assertEqual(fwdref, x[y])
101
102 def test_function(self):
103 def f(x: int, y: doesntexist):
104 pass
105
106 anno = get_annotations(f, format=Format.FORWARDREF)
107 self.assertIs(anno["x"], int)
108 fwdref = anno["y"]
109 self.assertIsInstance(fwdref, ForwardRef)
110 self.assertEqual(fwdref.__forward_arg__, "doesntexist")
111 with self.assertRaises(NameError):
112 fwdref.evaluate()
113 self.assertEqual(fwdref.evaluate(globals={"doesntexist": 1}), 1)
114
115 def test_nonexistent_attribute(self):
116 def f(

Callers

nothing calls this directly

Calls 6

get_annotationsFunction · 0.90
assertIsInstanceMethod · 0.80
assertIsMethod · 0.45
assertEqualMethod · 0.45
assertRaisesMethod · 0.45
evaluateMethod · 0.45

Tested by

no test coverage detected