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

Method test_slots_weakref_base_str

Lib/test/test_dataclasses/__init__.py:3698–3710  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3696 self.assertIs(a.__weakref__, a_ref)
3697
3698 def test_slots_weakref_base_str(self):
3699 class Base:
3700 __slots__ = '__weakref__'
3701
3702 @dataclass(slots=True)
3703 class A(Base):
3704 a: int
3705
3706 # __weakref__ is in the base class, not A. But an A is still weakref-able.
3707 self.assertIn("__weakref__", Base.__slots__)
3708 self.assertNotIn("__weakref__", A.__slots__)
3709 a = A(1)
3710 weakref.ref(a)
3711
3712 def test_slots_weakref_base_tuple(self):
3713 # Same as test_slots_weakref_base, but use a tuple instead of a string

Callers

nothing calls this directly

Calls 3

assertInMethod · 0.80
assertNotInMethod · 0.80
AClass · 0.70

Tested by

no test coverage detected