Skip to content

Commit c61cf9d

Browse files
committed
add-tests-for-generic-annotations
1 parent e34479d commit c61cf9d

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/test_completer.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,43 @@ def test_undefined_variables(use_jedi, evaluation, code, insert_text):
25112511
assert len(match) == 1, message_on_fail
25122512

25132513

2514+
@pytest.mark.parametrize(
2515+
"code,insert_text",
2516+
[
2517+
[
2518+
"\n".join(
2519+
[
2520+
"t: dict = {'a': []}",
2521+
"t['a'].",
2522+
]
2523+
),
2524+
["append"],
2525+
],
2526+
[
2527+
"\n".join(
2528+
[
2529+
"t: list = ['test']",
2530+
"t[0].",
2531+
]
2532+
),
2533+
["capitalize"],
2534+
],
2535+
],
2536+
)
2537+
def test_undefined_variables_without_jedi(code, insert_text):
2538+
offset = len(code)
2539+
ip.Completer.use_jedi = False
2540+
ip.Completer.evaluation = "limited"
2541+
2542+
with provisionalcompleter():
2543+
completions = list(ip.Completer.completions(text=code, offset=offset))
2544+
insert_texts = insert_text if isinstance(insert_text, list) else [insert_text]
2545+
for text in insert_texts:
2546+
match = [c for c in completions if c.text.lstrip(".") == text]
2547+
message_on_fail = f"{text} not found among {[c.text for c in completions]}"
2548+
assert len(match) == 1, message_on_fail
2549+
2550+
25142551
@pytest.mark.parametrize(
25152552
"code",
25162553
[

0 commit comments

Comments
 (0)