From 2c83b296a404801131408f10442089268ee79822 Mon Sep 17 00:00:00 2001 From: Taus Date: Mon, 8 Dec 2025 17:12:21 +0000 Subject: [PATCH] Python: Add parser test Note in particular that the `exceptions.py` test is unaffected. --- .../parser/exception_groups_new.expected | 26 +++++++- .../tests/parser/exception_groups_new.py | 5 ++ .../tests/parser/exceptions_new.expected | 64 +++++++++++++++++++ .../extractor/tests/parser/exceptions_new.py | 8 +++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 python/extractor/tests/parser/exceptions_new.expected create mode 100644 python/extractor/tests/parser/exceptions_new.py diff --git a/python/extractor/tests/parser/exception_groups_new.expected b/python/extractor/tests/parser/exception_groups_new.expected index a70bf1b2485..337d12f6339 100644 --- a/python/extractor/tests/parser/exception_groups_new.expected +++ b/python/extractor/tests/parser/exception_groups_new.expected @@ -1,4 +1,4 @@ -Module: [1, 0] - [27, 0] +Module: [1, 0] - [32, 0] body: [ Try: [1, 0] - [1, 4] body: [ @@ -153,4 +153,28 @@ Module: [1, 0] - [27, 0] ] ] finalbody: [] + Try: [28, 0] - [28, 4] + body: [ + Pass: [29, 4] - [29, 8] + ] + orelse: [] + handlers: [ + ExceptGroupStmt: [30, 0] - [31, 8] + type: + Tuple: [30, 8] - [30, 12] + elts: [ + Name: [30, 8] - [30, 9] + variable: Variable('x', None) + ctx: Load + Name: [30, 11] - [30, 12] + variable: Variable('y', None) + ctx: Load + ] + ctx: Load + name: None + body: [ + Pass: [31, 4] - [31, 8] + ] + ] + finalbody: [] ] diff --git a/python/extractor/tests/parser/exception_groups_new.py b/python/extractor/tests/parser/exception_groups_new.py index 01fe58b9a98..e16ca18be35 100644 --- a/python/extractor/tests/parser/exception_groups_new.py +++ b/python/extractor/tests/parser/exception_groups_new.py @@ -24,3 +24,8 @@ try: pass except *foo as e: pass + +try: + pass +except* x, y: + pass diff --git a/python/extractor/tests/parser/exceptions_new.expected b/python/extractor/tests/parser/exceptions_new.expected new file mode 100644 index 00000000000..ca713146e50 --- /dev/null +++ b/python/extractor/tests/parser/exceptions_new.expected @@ -0,0 +1,64 @@ +Module: [1, 0] - [9, 0] + body: [ + Try: [1, 0] - [1, 4] + body: [ + Pass: [2, 4] - [2, 8] + ] + orelse: [] + handlers: [ + ExceptStmt: [3, 0] - [3, 12] + type: + Tuple: [3, 7] - [3, 11] + elts: [ + Name: [3, 7] - [3, 8] + variable: Variable('a', None) + ctx: Load + Name: [3, 10] - [3, 11] + variable: Variable('b', None) + ctx: Load + ] + ctx: Load + name: None + body: [ + Pass: [4, 4] - [4, 8] + ] + ExceptStmt: [5, 0] - [5, 14] + type: + Tuple: [5, 8] - [5, 12] + elts: [ + Name: [5, 8] - [5, 9] + variable: Variable('c', None) + ctx: Load + Name: [5, 11] - [5, 12] + variable: Variable('d', None) + ctx: Load + ] + ctx: Load + parenthesised: True + name: None + body: [ + Pass: [6, 4] - [6, 8] + ] + ExceptStmt: [7, 0] - [7, 19] + type: + Tuple: [7, 8] - [7, 12] + elts: [ + Name: [7, 8] - [7, 9] + variable: Variable('e', None) + ctx: Load + Name: [7, 11] - [7, 12] + variable: Variable('f', None) + ctx: Load + ] + ctx: Load + parenthesised: True + name: + Name: [7, 17] - [7, 18] + variable: Variable('g', None) + ctx: Store + body: [ + Pass: [8, 4] - [8, 8] + ] + ] + finalbody: [] + ] diff --git a/python/extractor/tests/parser/exceptions_new.py b/python/extractor/tests/parser/exceptions_new.py new file mode 100644 index 00000000000..b2e7d943e1d --- /dev/null +++ b/python/extractor/tests/parser/exceptions_new.py @@ -0,0 +1,8 @@ +try: + pass +except a, b: # new, relaxed syntax + pass +except (c, d): # old syntax + pass +except (e, f) as g: # old syntax + pass