From 0e8f7a3ace269ad0229b6cef56ff6aef5e06a8b0 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Sun, 5 Jan 2020 03:12:58 -0800 Subject: Add missing test cases --- tests/test_isort.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 -- cgit v1.2.1