diff options
| author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2017-10-30 00:25:20 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-30 00:25:20 -0700 |
| commit | 570cbc721f09cecaec3a6245047ab9fb2d664f35 (patch) | |
| tree | 714d905167f21e511172689e67ac35df2ab90754 /test_isort.py | |
| parent | bc3cda5928c3b6d03639a90b6bd41a2c964f6af6 (diff) | |
| parent | 3105d17be4a98bf2b5a0c7c0bea06419b235d203 (diff) | |
| download | isort-570cbc721f09cecaec3a6245047ab9fb2d664f35.tar.gz | |
Merge branch 'develop' into develop
Diffstat (limited to 'test_isort.py')
| -rw-r--r-- | test_isort.py | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test_isort.py b/test_isort.py index 97906510..6dbb7c2b 100644 --- a/test_isort.py +++ b/test_isort.py @@ -1635,7 +1635,7 @@ def test_comment_at_top_of_file(): def test_alphabetic_sorting(): - """Test to ensure isort correctly handles top of file comments""" + """Test to ensure isort correctly handles single line imports""" test_input = ("import unittest\n" "\n" "import ABC\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' @@ -2212,3 +2212,30 @@ def test_ensure_line_endings_are_preserved_issue_493(): test_input = ('from os import defpath\n' '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' + firstparty_section = 'from app.pkg1 import mdl1\n' + local_section = 'from .pkg2 import mdl2\n' + statement = 'foo = bar\n' + test_input = ( + stdlib_section + whiteline + firstparty_section + whiteline + + local_section + whiteline + statement + ) + + assert SortImports(file_contents=test_input).output == test_input + assert SortImports(file_contents=test_input, no_lines_before=['LOCALFOLDER']).output == \ + ( + stdlib_section + whiteline + firstparty_section + local_section + + whiteline + statement + ) + assert SortImports(file_contents=test_input, no_lines_before=['FIRSTPARTY']).output == \ + ( + stdlib_section + firstparty_section + whiteline + local_section + + whiteline + statement + ) + assert SortImports(file_contents=test_input, no_lines_before=['FIRSTPARTY', 'LOCALFOLDER']).output == \ + (stdlib_section + firstparty_section + local_section + whiteline + statement) + |
