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

Method test_parameterized_slots

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

Source from the content-addressed store, hash-verified

5408 self.assertEqual(weakref.ref(t)(), t)
5409
5410 def test_parameterized_slots(self):
5411 T = TypeVar('T')
5412 class C(Generic[T]):
5413 __slots__ = ('potato',)
5414
5415 c = C()
5416 c_int = C[int]()
5417
5418 c.potato = 0
5419 c_int.potato = 0
5420 with self.assertRaises(AttributeError):
5421 c.tomato = 0
5422 with self.assertRaises(AttributeError):
5423 c_int.tomato = 0
5424
5425 def foo(x: C['C']): ...
5426 self.assertEqual(get_type_hints(foo, globals(), locals())['x'], C[C])
5427 self.assertEqual(copy(C[int]), deepcopy(C[int]))
5428
5429 def test_parameterized_slots_dict(self):
5430 T = TypeVar('T')

Callers

nothing calls this directly

Calls 9

get_type_hintsFunction · 0.90
copyFunction · 0.90
deepcopyFunction · 0.90
TypeVarClass · 0.85
globalsFunction · 0.85
localsFunction · 0.85
CClass · 0.70
assertRaisesMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected