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

Method test_other_params

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

Source from the content-addressed store, hash-verified

4428 self.assertEqual(C.z, 20)
4429
4430 def test_other_params(self):
4431 C = make_dataclass('C',
4432 [('x', int),
4433 ('y', ClassVar[int], 10),
4434 ('z', ClassVar[int], field(default=20)),
4435 ],
4436 init=False)
4437 # Make sure we have a repr, but no init.
4438 self.assertNotIn('__init__', vars(C))
4439 self.assertIn('__repr__', vars(C))
4440
4441 # Make sure random other params don't work.
4442 with self.assertRaisesRegex(TypeError, 'unexpected keyword argument'):
4443 C = make_dataclass('C',
4444 [],
4445 xxinit=False)
4446
4447 def test_no_types(self):
4448 C = make_dataclass('Point', ['x', 'y', 'z'])

Callers

nothing calls this directly

Calls 5

make_dataclassFunction · 0.85
fieldFunction · 0.85
assertNotInMethod · 0.80
assertInMethod · 0.80
assertRaisesRegexMethod · 0.80

Tested by

no test coverage detected