diff options
| author | Krzysztof Chomski <krzysztof.chomski@reef.pl> | 2017-11-14 14:16:19 +0100 |
|---|---|---|
| committer | Dawid Manikowski <dawid.manikowski@reef.pl> | 2017-12-21 13:53:17 +0100 |
| commit | f6c919b6ebaa4654c885cc172087cf87d0b52075 (patch) | |
| tree | 64c5dfca1fc8d8f1923e173e678d02943aa19911 /test_isort.py | |
| parent | 08ef3a184429cb5a57a740c473ce0871816890b4 (diff) | |
| download | isort-f6c919b6ebaa4654c885cc172087cf87d0b52075.tar.gz | |
GH512: Add an option to ignore order within a single import statement.
Diffstat (limited to 'test_isort.py')
| -rw-r--r-- | test_isort.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test_isort.py b/test_isort.py index 6dbb7c2b..6e7ee0e8 100644 --- a/test_isort.py +++ b/test_isort.py @@ -2074,7 +2074,7 @@ def test_ignore_whitespace(capsys): def test_import_wraps_with_comment_issue_471(): - """Test to insure issue #471 is resolved""" + """Test to ensure issue #471 is resolved""" test_input = ('from very_long_module_name import SuperLongClassName #@UnusedImport' ' -- long string of comments which wrap over') expected_output = ('from very_long_module_name import (\n' @@ -2200,7 +2200,7 @@ def test_ensure_as_imports_sort_correctly_within_from_imports_issue_590(): 'from os import pathsep as separator\n') assert SortImports(file_contents=test_input, force_single_line=True).output == test_input - + def test_ensure_line_endings_are_preserved_issue_493(): """Test to ensure line endings are not converted""" test_input = ('from os import defpath\r\n' @@ -2213,7 +2213,7 @@ def test_ensure_line_endings_are_preserved_issue_493(): 'from os import pathsep as separator\n') assert SortImports(file_contents=test_input).output == test_input - + def test_not_splitted_sections(): whiteline = '\n' stdlib_section = 'import unittest\n' @@ -2239,3 +2239,18 @@ def test_not_splitted_sections(): assert SortImports(file_contents=test_input, no_lines_before=['FIRSTPARTY', 'LOCALFOLDER']).output == \ (stdlib_section + firstparty_section + local_section + whiteline + statement) + +def test_no_inline_sort(): + """Test to ensure multiple `from` imports in one line are not sorted if `--no-inline-sort` flag + is enabled. If `--force-single-line-imports` flag is enabled, then `--no-inline-sort` is omitted.""" + test_input = 'from foo import a, c, b\n' + assert SortImports(file_contents=test_input, no_inline_sort=True, force_single_line=False).output == test_input + assert SortImports(file_contents=test_input, no_inline_sort=False, force_single_line=False).output == 'from foo import a, b, c\n' + expected = ( + 'from foo import a\n' + 'from foo import b\n' + 'from foo import c\n' + ) + assert SortImports(file_contents=test_input, no_inline_sort=False, force_single_line=True).output == expected + assert SortImports(file_contents=test_input, no_inline_sort=True, force_single_line=True).output == expected + |
