MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_instantiate

Method test_instantiate

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

defaultdictClass · 0.90
iterFunction · 0.85
subTestMethod · 0.80
tFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected