Skip to content

Commit

Permalink
Add test to check for infinite loop on unmatched parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudnits committed Apr 13, 2022
1 parent bcfb022 commit a4f8fb6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/unit/test_isort.py
Expand Up @@ -5562,3 +5562,21 @@ def seekable(self):
test_input = NonSeekableTestStream("import m2\n" "import m1\n" "not_import = 7")
identified_imports = list(map(str, api.find_imports_in_stream(test_input)))
assert identified_imports == [":1 import m2", ":2 import m1"]


def test_infinite_loop_in_unmatched_parenthesis() -> None:
test_input = "from os import ("

# ensure a syntax error is raised for unmatched parenthesis
with pytest.raises(ExistingSyntaxErrors):
isort.code(test_input)

test_input = """from os import (
path,
walk
)
"""

# ensure other cases are handled correctly
assert isort.code(test_input) == "from os import path, walk\n"

0 comments on commit a4f8fb6

Please sign in to comment.