mirror of
https://github.com/python/cpython.git
synced 2025-08-01 23:53:15 +00:00
Added kw_only parameter to make_dataclasses. (GH-29679)
(cherry picked from commit f7638dd0f9
)
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
This commit is contained in:
parent
3528df1258
commit
cf8c8788c9
3 changed files with 14 additions and 2 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue