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

Method test_slots_no_weakref

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

Source from the content-addressed store, hash-verified

3671 self.assertEqual(obj.b, 'b')
3672
3673 def test_slots_no_weakref(self):
3674 @dataclass(slots=True)
3675 class A:
3676 # No weakref.
3677 pass
3678
3679 self.assertNotIn("__weakref__", A.__slots__)
3680 a = A()
3681 with self.assertRaisesRegex(TypeError,
3682 "cannot create weak reference"):
3683 weakref.ref(a)
3684 with self.assertRaises(AttributeError):
3685 a.__weakref__
3686
3687 def test_slots_weakref(self):
3688 @dataclass(slots=True, weakref_slot=True)

Callers

nothing calls this directly

Calls 4

assertNotInMethod · 0.80
assertRaisesRegexMethod · 0.80
AClass · 0.70
assertRaisesMethod · 0.45

Tested by

no test coverage detected