summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2020-01-05 03:12:58 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2020-01-05 03:12:58 -0800
commit0e8f7a3ace269ad0229b6cef56ff6aef5e06a8b0 (patch)
treef119649c49dd72767a3acc8a914cc40e70b21b05
parent725578a19f3a09d754467068b3c0bf3c23c73365 (diff)
downloadisort-0e8f7a3ace269ad0229b6cef56ff6aef5e06a8b0.tar.gz
Add missing test cases
-rw-r--r--tests/test_isort.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/test_isort.py b/tests/test_isort.py
index 34fa7bc6..0bed7f49 100644
--- a/tests/test_isort.py
+++ b/tests/test_isort.py
@@ -963,6 +963,23 @@ def test_force_single_line_imports() -> None:
"from third_party import lib22\n"
)
+ test_input = (
+ "from third_party import lib_a, lib_b, lib_d\n"
+ "from third_party.lib_c import lib1\n"
+ )
+ test_output = SortImports(
+ file_contents=test_input,
+ multi_line_output=WrapModes.GRID,
+ line_length=40,
+ force_single_line=True,
+ ).output
+ assert test_output == (
+ "from third_party import lib_a\n"
+ "from third_party import lib_b\n"
+ "from third_party import lib_d\n"
+ "from third_party.lib_c import lib1\n"
+ )
+
def test_force_single_line_long_imports() -> None:
test_input = "from veryveryveryveryveryvery import small, big\n"
@@ -4597,3 +4614,12 @@ IF CEF_VERSION == 3:
from web_request_client_cef3 cimport *
"""
SortImports(file_contents=test_input).output == expected_output
+
+
+def test_top_level_import_order() -> None:
+ config = {"force_sort_within_sections": 1} # type: Dict[str, Any]
+ test_input = (
+ "from rest_framework import throttling, viewsets\n"
+ "from rest_framework.authentication import TokenAuthentication\n"
+ )
+ assert SortImports(file_contents=test_input, **config).output == test_input