(self)
| 1096 | self.assertTrue(flag) |
| 1097 | |
| 1098 | def test_post_init_classmethod(self): |
| 1099 | @dataclass |
| 1100 | class C: |
| 1101 | flag = False |
| 1102 | x: int |
| 1103 | y: int |
| 1104 | @classmethod |
| 1105 | def __post_init__(cls): |
| 1106 | cls.flag = True |
| 1107 | |
| 1108 | self.assertFalse(C.flag) |
| 1109 | c = C(3, 4) |
| 1110 | self.assertEqual((c.x, c.y), (3, 4)) |
| 1111 | self.assertTrue(C.flag) |
| 1112 | |
| 1113 | def test_post_init_not_auto_added(self): |
| 1114 | # See bpo-46757, which had proposed always adding __post_init__. As |
nothing calls this directly
no test coverage detected