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

Method test_multiple_closure

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

Source from the content-addressed store, hash-verified

76 self.assertEqual(anno["arg"], x)
77
78 def test_multiple_closure(self):
79 def inner(arg: x[y]):
80 pass
81
82 fwdref = get_annotations(inner, format=Format.FORWARDREF)["arg"]
83 self.assertIsInstance(fwdref, ForwardRef)
84 self.assertEqual(fwdref.__forward_arg__, "x[y]")
85 with self.assertRaises(NameError):
86 fwdref.evaluate()
87
88 y = str
89 fwdref = get_annotations(inner, format=Format.FORWARDREF)["arg"]
90 self.assertIsInstance(fwdref, ForwardRef)
91 extra_name, extra_val = next(iter(fwdref.__extra_names__.items()))
92 self.assertEqual(fwdref.__forward_arg__.replace(extra_name, extra_val.__name__), "x[str]")
93 with self.assertRaises(NameError):
94 fwdref.evaluate()
95
96 x = list
97 self.assertEqual(fwdref.evaluate(), x[y])
98
99 fwdref = get_annotations(inner, format=Format.FORWARDREF)["arg"]
100 self.assertEqual(fwdref, x[y])
101
102 def test_function(self):
103 def f(x: int, y: doesntexist):

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected