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

Method test_class_var

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

Source from the content-addressed store, hash-verified

4416 self.assertEqual(len(fields(c)), 1)
4417
4418 def test_class_var(self):
4419 C = make_dataclass('C',
4420 [('x', int),
4421 ('y', ClassVar[int], 10),
4422 ('z', ClassVar[int], field(default=20)),
4423 ])
4424 c = C(1)
4425 self.assertEqual(vars(c), {'x': 1})
4426 self.assertEqual(len(fields(c)), 1)
4427 self.assertEqual(C.y, 10)
4428 self.assertEqual(C.z, 20)
4429
4430 def test_other_params(self):
4431 C = make_dataclass('C',

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected