Skip to content

Commit

Permalink
test_find_names: add more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed May 10, 2020
1 parent 5aa15e9 commit 9be0fff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/test_find_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ def test_builtins():
def test_loops():
check_find_names("for x in y: print(x)", {"x"}, {"y", "print"})
check_find_names("while x: pass", set(), {"x"})
check_find_names("for x in x: pass", {"x"}, {"x"})


def test_weird_assignments():
check_find_names("x += 1", {"x"}, {"x"})
check_find_names("for x in x: pass", {"x"}, {"x"})
check_find_names("x, y = x, y", {"x", "y"}, {"x", "y"})
check_find_names("x: int = 1", {"x"}, {"int"})
check_find_names("x: int = x", {"x"}, {"int", "x"})


@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires python 3.8 or later")
Expand All @@ -46,7 +49,10 @@ def test_comprehensions():
check_find_names("(x for x in x)", {"x"}, {"x"})
check_find_names("(x for xx in xxx for x in xx)", {"x", "xx"}, {"xxx"})
check_find_names("(x for x in xx for xx in xxx)", {"x", "xx"}, {"xx", "xxx"})
check_find_names("(x for x in xx if x == 'foo')", {"x"}, {"xx"})
check_find_names("(x for x in xx if x > 0)", {"x"}, {"xx"})
check_find_names("[x for x in xx if x > 0]", {"x"}, {"xx"})
check_find_names("{x for x in xx if x > 0}", {"x"}, {"xx"})
check_find_names("{x: x for x in xx if x > 0}", {"x"}, {"xx"})


def test_args():
Expand Down

0 comments on commit 9be0fff

Please sign in to comment.