summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_positional_only_arg.py
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2020-06-10 13:07:06 (GMT)
committerGitHub <noreply@github.com>2020-06-10 13:07:06 (GMT)
commitc6483c989694cfa328dabd45eb191440da54bc68 (patch)
treeab9692a04c460323035c804d9ed8c64bc5bdc866 /Lib/test/test_positional_only_arg.py
parent0d00b2a5d74390da7bbeff7dfa73abf2eb46124a (diff)
downloadcpython-c6483c989694cfa328dabd45eb191440da54bc68.zip
cpython-c6483c989694cfa328dabd45eb191440da54bc68.tar.gz
cpython-c6483c989694cfa328dabd45eb191440da54bc68.tar.bz2
Raise specialised syntax error for invalid lambda parameters (GH-20776)
Diffstat (limited to 'Lib/test/test_positional_only_arg.py')
-rw-r--r--Lib/test/test_positional_only_arg.py30
1 files changed, 12 insertions, 18 deletions
diff --git a/Lib/test/test_positional_only_arg.py b/Lib/test/test_positional_only_arg.py
index f7bd401..0a9503e 100644
--- a/Lib/test/test_positional_only_arg.py
+++ b/Lib/test/test_positional_only_arg.py
@@ -4,7 +4,7 @@ import dis
import pickle
import unittest
-from test.support import check_syntax_error, use_old_parser
+from test.support import check_syntax_error
def global_pos_only_f(a, b, /):
@@ -23,12 +23,10 @@ class PositionalOnlyTestCase(unittest.TestCase):
compile(codestr + "\n", "<test>", "single")
def test_invalid_syntax_errors(self):
- if use_old_parser():
- 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", "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(*args, /): pass")
check_syntax_error(self, "def f(*args, a, /): pass")
check_syntax_error(self, "def f(**kwargs, /): pass")
@@ -46,12 +44,10 @@ class PositionalOnlyTestCase(unittest.TestCase):
check_syntax_error(self, "def f(a, *, c, /, d, e): pass")
def test_invalid_syntax_errors_async(self):
- if use_old_parser():
- 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", "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(*args, /): pass")
check_syntax_error(self, "async def f(*args, a, /): pass")
check_syntax_error(self, "async def f(**kwargs, /): pass")
@@ -235,11 +231,9 @@ class PositionalOnlyTestCase(unittest.TestCase):
self.assertEqual(x(1, 2), 3)
def test_invalid_syntax_lambda(self):
- if use_old_parser():
- 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", "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 *args, /: None")
check_syntax_error(self, "lambda *args, a, /: None")
check_syntax_error(self, "lambda **kwargs, /: None")