summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dataclasses.py
diff options
context:
space:
mode:
authorEric V. Smith <ericvsmith@users.noreply.github.com>2018-01-06 22:09:58 (GMT)
committerGitHub <noreply@github.com>2018-01-06 22:09:58 (GMT)
commitd80b443f02e087dd289ffefd04179c675304d76d (patch)
tree7bb88766e76f10fc71713037c5615a5bd84cecb8 /Lib/test/test_dataclasses.py
parented7d429ebb591f65cef558760fb4ebdc4fc8f8b0 (diff)
downloadcpython-d80b443f02e087dd289ffefd04179c675304d76d.zip
cpython-d80b443f02e087dd289ffefd04179c675304d76d.tar.gz
cpython-d80b443f02e087dd289ffefd04179c675304d76d.tar.bz2
bpo-32279: Add additional params to make_dataclass(), pass through to dataclass(). (gh-5117)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rwxr-xr-xLib/test/test_dataclasses.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py
index c44c53d..69819ea 100755
--- a/Lib/test/test_dataclasses.py
+++ b/Lib/test/test_dataclasses.py
@@ -2033,6 +2033,23 @@ class TestCase(unittest.TestCase):
self.assertEqual(C.y, 10)
self.assertEqual(C.z, 20)
+ def test_helper_make_dataclass_other_params(self):
+ C = make_dataclass('C',
+ [('x', int),
+ ('y', ClassVar[int], 10),
+ ('z', ClassVar[int], field(default=20)),
+ ],
+ init=False)
+ # Make sure we have a repr, but no init.
+ self.assertNotIn('__init__', vars(C))
+ self.assertIn('__repr__', vars(C))
+
+ # Make sure random other params don't work.
+ with self.assertRaisesRegex(TypeError, 'unexpected keyword argument'):
+ C = make_dataclass('C',
+ [],
+ xxinit=False)
+
def test_helper_make_dataclass_no_types(self):
C = make_dataclass('Point', ['x', 'y', 'z'])
c = C(1, 2, 3)