Skip to content

Commit 152b4ca

Browse files
more cleanup
1 parent a708a78 commit 152b4ca

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

tests/unittest_inference.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6631,34 +6631,55 @@ def test_imported_module_var_inferable() -> None:
66316631
"""
66326632
Module variables can be imported and inferred successfully as part of binary operators.
66336633
"""
6634-
mod1 = parse("from top1.mod import v as z\n" + "w = [1] + z", module_name="top1")
6634+
mod1 = parse(
6635+
textwrap.dedent(
6636+
"""
6637+
from top1.mod import v as z
6638+
w = [1] + z
6639+
"""
6640+
),
6641+
module_name="top1",
6642+
)
66356643
parse("v = [2]", module_name="top1.mod")
66366644
w_val = mod1.body[-1].value
66376645
i_w_val = next(w_val.infer())
6638-
assert i_w_val != util.Uninferable
6646+
assert i_w_val is not util.Uninferable
66396647
assert i_w_val.as_string() == "[1, 2]"
66406648

66416649

66426650
def test_imported_module_var_inferable2() -> None:
66436651
"""Version list of strings."""
6644-
mod1 = parse("from top2.mod import v as z\n" + "w = ['1'] + z", module_name="top2")
6652+
mod2 = parse(
6653+
textwrap.dedent(
6654+
"""
6655+
from top2.mod import v as z
6656+
w = ['1'] + z
6657+
"""
6658+
),
6659+
module_name="top2",
6660+
)
66456661
parse("v = ['2']", module_name="top2.mod")
6646-
w_val = mod1.body[-1].value
6662+
w_val = mod2.body[-1].value
66476663
i_w_val = next(w_val.infer())
6648-
assert i_w_val != util.Uninferable
6664+
assert i_w_val is not util.Uninferable
66496665
assert i_w_val.as_string() == "['1', '2']"
66506666

66516667

66526668
def test_imported_module_var_inferable3() -> None:
66536669
"""Version list of strings with a __dunder__ name."""
6654-
mod1 = parse(
6655-
"from top3.mod import __dunder_var__ as v\n" + "__dunder_var__ = ['w'] + v",
6670+
mod3 = parse(
6671+
textwrap.dedent(
6672+
"""
6673+
from top3.mod import __dunder_var__ as v
6674+
__dunder_var__ = ['w'] + v
6675+
"""
6676+
),
66566677
module_name="top",
66576678
)
66586679
parse("__dunder_var__ = ['v']", module_name="top3.mod")
6659-
w_val = mod1.body[-1].value
6680+
w_val = mod3.body[-1].value
66606681
i_w_val = next(w_val.infer())
6661-
assert i_w_val != util.Uninferable
6682+
assert i_w_val is not util.Uninferable
66626683
assert i_w_val.as_string() == "['w', 'v']"
66636684

66646685

0 commit comments

Comments
 (0)