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

Method test_parameterized_slots

Lib/test/test_typing.py:5517–5534  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

5515 self.assertEqual(weakref.ref(t)(), t)
5516
5517 def test_parameterized_slots(self):
5518 T = TypeVar('T')
5519 class C(Generic[T]):
5520 __slots__ = ('potato',)
5521
5522 c = C()
5523 c_int = C[int]()
5524
5525 c.potato = 0
5526 c_int.potato = 0
5527 with self.assertRaises(AttributeError):
5528 c.tomato = 0
5529 with self.assertRaises(AttributeError):
5530 c_int.tomato = 0
5531
5532 def foo(x: C['C']): ...
5533 self.assertEqual(get_type_hints(foo, globals(), locals())['x'], C[C])
5534 self.assertEqual(copy(C[int]), deepcopy(C[int]))
5535
5536 def test_parameterized_slots_dict(self):
5537 T = TypeVar('T')

Callers

nothing calls this directly

Calls 6

get_type_hintsFunction · 0.90
copyFunction · 0.90
deepcopyFunction · 0.90
CClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected