Skip to content

Commit

Permalink
test_find_names: test more control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed May 10, 2020
1 parent 9be0fff commit bbf181b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_find_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ def test_weird_assignments():
check_find_names("x: int = x", {"x"}, {"int", "x"})


def test_more_control_flow():
check_find_names("try: x = 1\nexcept: x", {"x"}, set())
check_find_names("try: x = 1\nexcept: y", {"x"}, {"y"})
check_find_names("try: x = 1\nexcept: y\nfinally: x", {"x"}, {"y"})
check_find_names("try: x = 1\nexcept: y\nfinally: z", {"x"}, {"y", "z"})
check_find_names("with a as x: x", {"x"}, {"a"})
check_find_names("with a as x, b as y: x", {"x", "y"}, {"a", "b"})
check_find_names("with a as b, b as c: c", {"b", "c"}, {"a"})
check_find_names("with a as c, b as c: c", {"c"}, {"a", "b"})


@pytest.mark.skipif(sys.version_info < (3, 8), reason="requires python 3.8 or later")
def test_walrus():
check_find_names("(x := x)", {"x"}, {"x"})
Expand Down

0 comments on commit bbf181b

Please sign in to comment.