diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-11-20 15:46:56 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 15:46:56 -0800 |
commit | cf8c8788c904cce68b0ab1d39900483f50983301 (patch) | |
tree | cc9a5b38099b834c19fc244c9d79690de8700ad7 /Lib/test/test_dataclasses.py | |
parent | 3528df12581e8ccf3fae6d25bd9687ae55424398 (diff) | |
download | cpython-git-cf8c8788c904cce68b0ab1d39900483f50983301.tar.gz |
Added kw_only parameter to make_dataclasses. (GH-29679)
(cherry picked from commit f7638dd0f90b2afd9295ee179119f4a29859953a)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r-- | Lib/test/test_dataclasses.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index bbbb8e6c63..b00d0484d3 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -3864,5 +3864,16 @@ class TestKeywordArgs(unittest.TestCase): c: int = 1 d: int + def test_make_dataclass(self): + A = make_dataclass("A", ['a'], kw_only=True) + self.assertTrue(fields(A)[0].kw_only) + + B = make_dataclass("B", + ['a', ('b', int, field(kw_only=False))], + kw_only=True) + self.assertTrue(fields(B)[0].kw_only) + self.assertFalse(fields(B)[1].kw_only) + + if __name__ == '__main__': unittest.main() |