summaryrefslogtreecommitdiff
path: root/Lib/test/test_positional_only_arg.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_positional_only_arg.py')
-rw-r--r--Lib/test/test_positional_only_arg.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Lib/test/test_positional_only_arg.py b/Lib/test/test_positional_only_arg.py
index 0a9503e202..1a193814d7 100644
--- a/Lib/test/test_positional_only_arg.py
+++ b/Lib/test/test_positional_only_arg.py
@@ -23,10 +23,11 @@ class PositionalOnlyTestCase(unittest.TestCase):
compile(codestr + "\n", "<test>", "single")
def test_invalid_syntax_errors(self):
- check_syntax_error(self, "def f(a, b = 5, /, c): pass", "non-default argument follows default argument")
- check_syntax_error(self, "def f(a = 5, b, /, c): pass", "non-default argument follows default argument")
- check_syntax_error(self, "def f(a = 5, b=1, /, c, *, d=2): pass", "non-default argument follows default argument")
- check_syntax_error(self, "def f(a = 5, b, /): pass", "non-default argument follows default argument")
+ check_syntax_error(self, "def f(a, b = 5, /, c): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "def f(a = 5, b, /, c): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "def f(a = 5, b=1, /, c, *, d=2): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "def f(a = 5, b, /): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "def f(a, /, b = 5, c): pass", "parameter without a default follows parameter with a default")
check_syntax_error(self, "def f(*args, /): pass")
check_syntax_error(self, "def f(*args, a, /): pass")
check_syntax_error(self, "def f(**kwargs, /): pass")
@@ -44,10 +45,11 @@ class PositionalOnlyTestCase(unittest.TestCase):
check_syntax_error(self, "def f(a, *, c, /, d, e): pass")
def test_invalid_syntax_errors_async(self):
- check_syntax_error(self, "async def f(a, b = 5, /, c): pass", "non-default argument follows default argument")
- check_syntax_error(self, "async def f(a = 5, b, /, c): pass", "non-default argument follows default argument")
- check_syntax_error(self, "async def f(a = 5, b=1, /, c, d=2): pass", "non-default argument follows default argument")
- check_syntax_error(self, "async def f(a = 5, b, /): pass", "non-default argument follows default argument")
+ check_syntax_error(self, "async def f(a, b = 5, /, c): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "async def f(a = 5, b, /, c): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "async def f(a = 5, b=1, /, c, d=2): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "async def f(a = 5, b, /): pass", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "async def f(a, /, b = 5, c): pass", "parameter without a default follows parameter with a default")
check_syntax_error(self, "async def f(*args, /): pass")
check_syntax_error(self, "async def f(*args, a, /): pass")
check_syntax_error(self, "async def f(**kwargs, /): pass")
@@ -231,9 +233,11 @@ class PositionalOnlyTestCase(unittest.TestCase):
self.assertEqual(x(1, 2), 3)
def test_invalid_syntax_lambda(self):
- check_syntax_error(self, "lambda a, b = 5, /, c: None", "non-default argument follows default argument")
- check_syntax_error(self, "lambda a = 5, b, /, c: None", "non-default argument follows default argument")
- check_syntax_error(self, "lambda a = 5, b, /: None", "non-default argument follows default argument")
+ check_syntax_error(self, "lambda a, b = 5, /, c: None", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "lambda a = 5, b, /, c: None", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "lambda a = 5, b=1, /, c, *, d=2: None", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "lambda a = 5, b, /: None", "parameter without a default follows parameter with a default")
+ check_syntax_error(self, "lambda a, /, b = 5, c: None", "parameter without a default follows parameter with a default")
check_syntax_error(self, "lambda *args, /: None")
check_syntax_error(self, "lambda *args, a, /: None")
check_syntax_error(self, "lambda **kwargs, /: None")