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

Method test_closure

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

Source from the content-addressed store, hash-verified

59
60class TestForwardRefFormat(unittest.TestCase):
61 def test_closure(self):
62 def inner(arg: x):
63 pass
64
65 anno = get_annotations(inner, format=Format.FORWARDREF)
66 fwdref = anno["arg"]
67 self.assertIsInstance(fwdref, ForwardRef)
68 self.assertEqual(fwdref.__forward_arg__, "x")
69 with self.assertRaises(NameError):
70 fwdref.evaluate()
71
72 x = 1
73 self.assertEqual(fwdref.evaluate(), x)
74
75 anno = get_annotations(inner, format=Format.FORWARDREF)
76 self.assertEqual(anno["arg"], x)
77
78 def test_multiple_closure(self):
79 def inner(arg: x[y]):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected