Skip to content

Commit 47a2544

Browse files
Add text for name lookup
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
1 parent a87bbbd commit 47a2544

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

tests/test_group_exceptions.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55

66
import pytest
77

8-
from astroid import AssignName, ExceptHandler, For, Name, TryExcept, extract_node
8+
from astroid import (
9+
AssignName,
10+
ExceptHandler,
11+
For,
12+
Name,
13+
TryExcept,
14+
Uninferable,
15+
bases,
16+
extract_node,
17+
)
918
from astroid.const import PY311_PLUS
19+
from astroid.context import InferenceContext
1020
from astroid.nodes import Expr, Raise, TryStar
1121

1222

@@ -82,3 +92,20 @@ def test_star_exceptions() -> None:
8292
final = node.finalbody[0]
8393
assert isinstance(final, Expr)
8494
assert final.value.args[0].value == 0
95+
96+
97+
@pytest.mark.skipif(not PY311_PLUS, reason="Requires Python 3.11 or higher")
98+
def test_star_exceptions_infer_name() -> None:
99+
trystar = extract_node(
100+
"""
101+
try:
102+
1/0
103+
except* ValueError:
104+
pass"""
105+
)
106+
name = "arbitraryName"
107+
context = InferenceContext()
108+
context.lookupname = name
109+
stmts = bases._infer_stmts([trystar], context)
110+
assert list(stmts) == [Uninferable]
111+
assert context.lookupname == name

0 commit comments

Comments
 (0)