diff options
author | Eric V. Smith <ericvsmith@users.noreply.github.com> | 2023-08-10 14:39:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-10 14:39:13 (GMT) |
commit | e4275f4df36a7cdd58cd4daa7d65b1947a2593d3 (patch) | |
tree | b8dd0fb2998ded4b29a7abdd7ed99797c2558e80 /Lib/test/test_dataclasses.py | |
parent | 37d8b904f8b5b660f556597b21c0933b841d18de (diff) | |
download | cpython-e4275f4df36a7cdd58cd4daa7d65b1947a2593d3.zip cpython-e4275f4df36a7cdd58cd4daa7d65b1947a2593d3.tar.gz cpython-e4275f4df36a7cdd58cd4daa7d65b1947a2593d3.tar.bz2 |
gh-107838: In dataclasses, improve error message when a non-default field follows a default field. (gh-107842)
Add the name of the previous default argument field in an error message.
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r-- | Lib/test/test_dataclasses.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 6669f1c..bd8d824 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -134,7 +134,7 @@ class TestCase(unittest.TestCase): # Non-defaults following defaults. with self.assertRaisesRegex(TypeError, "non-default argument 'y' follows " - "default argument"): + "default argument 'x'"): @dataclass class C: x: int = 0 @@ -143,7 +143,7 @@ class TestCase(unittest.TestCase): # A derived class adds a non-default field after a default one. with self.assertRaisesRegex(TypeError, "non-default argument 'y' follows " - "default argument"): + "default argument 'x'"): @dataclass class B: x: int = 0 @@ -156,7 +156,7 @@ class TestCase(unittest.TestCase): # a field which didn't use to have a default. with self.assertRaisesRegex(TypeError, "non-default argument 'y' follows " - "default argument"): + "default argument 'x'"): @dataclass class B: x: int @@ -4521,7 +4521,7 @@ class TestKeywordArgs(unittest.TestCase): # Make sure we still check for non-kwarg non-defaults not following # defaults. - err_regex = "non-default argument 'z' follows default argument" + err_regex = "non-default argument 'z' follows default argument 'a'" with self.assertRaisesRegex(TypeError, err_regex): @dataclass class A: |