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

Method test_init_false_no_default

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

Source from the content-addressed store, hash-verified

634 assert False, f'unknown result {result!r}'
635
636 def test_init_false_no_default(self):
637 # If init=False and no default value, then the field won't be
638 # present in the instance.
639 @dataclass
640 class C:
641 x: int = field(init=False)
642
643 self.assertNotIn('x', C().__dict__)
644
645 @dataclass
646 class C:
647 x: int
648 y: int = 0
649 z: int = field(init=False)
650 t: int = 10
651
652 self.assertNotIn('z', C(0).__dict__)
653 self.assertEqual(vars(C(5)), {'t': 10, 'x': 5, 'y': 0})
654
655 def test_class_marker(self):
656 @dataclass

Callers

nothing calls this directly

Calls 3

assertNotInMethod · 0.95
assertEqualMethod · 0.95
CClass · 0.70

Tested by

no test coverage detected