diff options
author | Aniruddha <aniruddha97bhatt@gmail.com> | 2022-04-13 16:21:19 +0530 |
---|---|---|
committer | Aniruddha <aniruddha97bhatt@gmail.com> | 2022-04-13 16:21:19 +0530 |
commit | a4f8fb63f226122c24f376dd6f088098d113e7be (patch) | |
tree | b7f82361980b3b3a2f75252b32f731bc0926f36e | |
parent | bcfb0220acb9bc589451cc443161bacaa89736b4 (diff) | |
download | isort-a4f8fb63f226122c24f376dd6f088098d113e7be.tar.gz |
Add test to check for infinite loop on unmatched parenthesis
-rw-r--r-- | tests/unit/test_isort.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_isort.py b/tests/unit/test_isort.py index 293b99be..55de0f20 100644 --- a/tests/unit/test_isort.py +++ b/tests/unit/test_isort.py @@ -5562,3 +5562,21 @@ def test_find_imports_in_stream() -> None: 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" |