4
4
import pickle
5
5
import unittest
6
6
7
- from test .support import check_syntax_error , use_old_parser
7
+ from test .support import check_syntax_error
8
8
9
9
10
10
def global_pos_only_f (a , b , / ):
@@ -23,12 +23,10 @@ def assertRaisesSyntaxError(self, codestr, regex="invalid syntax"):
23
23
compile (codestr + "\n " , "<test>" , "single" )
24
24
25
25
def test_invalid_syntax_errors (self ):
26
- if use_old_parser ():
27
- check_syntax_error (self , "def f(a, b = 5, /, c): pass" , "non-default argument follows default argument" )
28
- check_syntax_error (self , "def f(a = 5, b, /, c): pass" , "non-default argument follows default argument" )
29
- check_syntax_error (self , "def f(a = 5, b=1, /, c, *, d=2): pass" , "non-default argument follows default argument" )
30
- check_syntax_error (self , "def f(a = 5, b, /): pass" , "non-default argument follows default argument" )
31
-
26
+ check_syntax_error (self , "def f(a, b = 5, /, c): pass" , "non-default argument follows default argument" )
27
+ check_syntax_error (self , "def f(a = 5, b, /, c): pass" , "non-default argument follows default argument" )
28
+ check_syntax_error (self , "def f(a = 5, b=1, /, c, *, d=2): pass" , "non-default argument follows default argument" )
29
+ check_syntax_error (self , "def f(a = 5, b, /): pass" , "non-default argument follows default argument" )
32
30
check_syntax_error (self , "def f(*args, /): pass" )
33
31
check_syntax_error (self , "def f(*args, a, /): pass" )
34
32
check_syntax_error (self , "def f(**kwargs, /): pass" )
@@ -46,12 +44,10 @@ def test_invalid_syntax_errors(self):
46
44
check_syntax_error (self , "def f(a, *, c, /, d, e): pass" )
47
45
48
46
def test_invalid_syntax_errors_async (self ):
49
- if use_old_parser ():
50
- check_syntax_error (self , "async def f(a, b = 5, /, c): pass" , "non-default argument follows default argument" )
51
- check_syntax_error (self , "async def f(a = 5, b, /, c): pass" , "non-default argument follows default argument" )
52
- check_syntax_error (self , "async def f(a = 5, b=1, /, c, d=2): pass" , "non-default argument follows default argument" )
53
- check_syntax_error (self , "async def f(a = 5, b, /): pass" , "non-default argument follows default argument" )
54
-
47
+ check_syntax_error (self , "async def f(a, b = 5, /, c): pass" , "non-default argument follows default argument" )
48
+ check_syntax_error (self , "async def f(a = 5, b, /, c): pass" , "non-default argument follows default argument" )
49
+ check_syntax_error (self , "async def f(a = 5, b=1, /, c, d=2): pass" , "non-default argument follows default argument" )
50
+ check_syntax_error (self , "async def f(a = 5, b, /): pass" , "non-default argument follows default argument" )
55
51
check_syntax_error (self , "async def f(*args, /): pass" )
56
52
check_syntax_error (self , "async def f(*args, a, /): pass" )
57
53
check_syntax_error (self , "async def f(**kwargs, /): pass" )
@@ -235,11 +231,9 @@ def test_lambdas(self):
235
231
self .assertEqual (x (1 , 2 ), 3 )
236
232
237
233
def test_invalid_syntax_lambda (self ):
238
- if use_old_parser ():
239
- check_syntax_error (self , "lambda a, b = 5, /, c: None" , "non-default argument follows default argument" )
240
- check_syntax_error (self , "lambda a = 5, b, /, c: None" , "non-default argument follows default argument" )
241
- check_syntax_error (self , "lambda a = 5, b, /: None" , "non-default argument follows default argument" )
242
-
234
+ check_syntax_error (self , "lambda a, b = 5, /, c: None" , "non-default argument follows default argument" )
235
+ check_syntax_error (self , "lambda a = 5, b, /, c: None" , "non-default argument follows default argument" )
236
+ check_syntax_error (self , "lambda a = 5, b, /: None" , "non-default argument follows default argument" )
243
237
check_syntax_error (self , "lambda *args, /: None" )
244
238
check_syntax_error (self , "lambda *args, a, /: None" )
245
239
check_syntax_error (self , "lambda **kwargs, /: None" )
0 commit comments