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

Method test_instantiate

Lib/test/test_genericalias.py:175–191  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

173 t[int]
174
175 def test_instantiate(self):
176 for t in tuple, list, dict, set, frozenset, defaultdict, deque:
177 tname = t.__name__
178 with self.subTest(f"Testing {tname}"):
179 alias = t[int]
180 self.assertEqual(alias(), t())
181 if t is dict:
182 self.assertEqual(alias(iter([('a', 1), ('b', 2)])), dict(a=1, b=2))
183 self.assertEqual(alias(a=1, b=2), dict(a=1, b=2))
184 elif t is defaultdict:
185 def default():
186 return 'value'
187 a = alias(default)
188 d = defaultdict(default)
189 self.assertEqual(a['test'], d['test'])
190 else:
191 self.assertEqual(alias(iter((1, 2, 3))), t((1, 2, 3)))
192
193 def test_unbound_methods(self):
194 t = list[int]

Callers

nothing calls this directly

Calls 4

tFunction · 0.85
defaultdictClass · 0.85
subTestMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected