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

Method test_init_var

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

Source from the content-addressed store, hash-verified

4402 self.assertEqual((c.x, c.y), (1, 2))
4403
4404 def test_init_var(self):
4405 def post_init(self, y):
4406 self.x *= y
4407
4408 C = make_dataclass('C',
4409 [('x', int),
4410 ('y', InitVar[int]),
4411 ],
4412 namespace={'__post_init__': post_init},
4413 )
4414 c = C(2, 3)
4415 self.assertEqual(vars(c), {'x': 6})
4416 self.assertEqual(len(fields(c)), 1)
4417
4418 def test_class_var(self):
4419 C = make_dataclass('C',

Callers

nothing calls this directly

Calls 4

make_dataclassFunction · 0.85
fieldsFunction · 0.85
CClass · 0.70
assertEqualMethod · 0.45

Tested by

no test coverage detected