Skip to content

Commit 8286483

Browse files
committed
Python: Add parser test
Note in particular that the `exceptions.py` test is unaffected.
1 parent 685f672 commit 8286483

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed

python/extractor/tests/parser/exception_groups_new.expected

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Module: [1, 0] - [27, 0]
1+
Module: [1, 0] - [32, 0]
22
body: [
33
Try: [1, 0] - [1, 4]
44
body: [
@@ -153,4 +153,28 @@ Module: [1, 0] - [27, 0]
153153
]
154154
]
155155
finalbody: []
156+
Try: [28, 0] - [28, 4]
157+
body: [
158+
Pass: [29, 4] - [29, 8]
159+
]
160+
orelse: []
161+
handlers: [
162+
ExceptGroupStmt: [30, 0] - [31, 8]
163+
type:
164+
Tuple: [30, 8] - [30, 12]
165+
elts: [
166+
Name: [30, 8] - [30, 9]
167+
variable: Variable('x', None)
168+
ctx: Load
169+
Name: [30, 11] - [30, 12]
170+
variable: Variable('y', None)
171+
ctx: Load
172+
]
173+
ctx: Load
174+
name: None
175+
body: [
176+
Pass: [31, 4] - [31, 8]
177+
]
178+
]
179+
finalbody: []
156180
]

python/extractor/tests/parser/exception_groups_new.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@
2424
pass
2525
except *foo as e:
2626
pass
27+
28+
try:
29+
pass
30+
except* x, y:
31+
pass
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
Module: [1, 0] - [9, 0]
2+
body: [
3+
Try: [1, 0] - [1, 4]
4+
body: [
5+
Pass: [2, 4] - [2, 8]
6+
]
7+
orelse: []
8+
handlers: [
9+
ExceptStmt: [3, 0] - [3, 12]
10+
type:
11+
Tuple: [3, 7] - [3, 11]
12+
elts: [
13+
Name: [3, 7] - [3, 8]
14+
variable: Variable('a', None)
15+
ctx: Load
16+
Name: [3, 10] - [3, 11]
17+
variable: Variable('b', None)
18+
ctx: Load
19+
]
20+
ctx: Load
21+
name: None
22+
body: [
23+
Pass: [4, 4] - [4, 8]
24+
]
25+
ExceptStmt: [5, 0] - [5, 14]
26+
type:
27+
Tuple: [5, 8] - [5, 12]
28+
elts: [
29+
Name: [5, 8] - [5, 9]
30+
variable: Variable('c', None)
31+
ctx: Load
32+
Name: [5, 11] - [5, 12]
33+
variable: Variable('d', None)
34+
ctx: Load
35+
]
36+
ctx: Load
37+
parenthesised: True
38+
name: None
39+
body: [
40+
Pass: [6, 4] - [6, 8]
41+
]
42+
ExceptStmt: [7, 0] - [7, 19]
43+
type:
44+
Tuple: [7, 8] - [7, 12]
45+
elts: [
46+
Name: [7, 8] - [7, 9]
47+
variable: Variable('e', None)
48+
ctx: Load
49+
Name: [7, 11] - [7, 12]
50+
variable: Variable('f', None)
51+
ctx: Load
52+
]
53+
ctx: Load
54+
parenthesised: True
55+
name:
56+
Name: [7, 17] - [7, 18]
57+
variable: Variable('g', None)
58+
ctx: Store
59+
body: [
60+
Pass: [8, 4] - [8, 8]
61+
]
62+
]
63+
finalbody: []
64+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
try:
2+
pass
3+
except a, b: # new, relaxed syntax
4+
pass
5+
except (c, d): # old syntax
6+
pass
7+
except (e, f) as g: # old syntax
8+
pass

0 commit comments

Comments
 (0)