diff options
| author | Timothy Crosley <timothy.crosley@gmail.com> | 2019-12-26 14:14:22 -0800 |
|---|---|---|
| committer | Timothy Crosley <timothy.crosley@gmail.com> | 2019-12-26 14:14:22 -0800 |
| commit | 955e5b73cff6ac54c91a3a4df46e9ef2fb772e18 (patch) | |
| tree | 0bf582587f60c9a634ff4b907145bccd9c9278be /tests | |
| parent | ecfe14a5745ca394267838cb12e4c93df57638b1 (diff) | |
| download | isort-feature/contiguous-import-sorting.tar.gz | |
Add support for nested import sectionsfeature/contiguous-import-sorting
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_isort.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_isort.py b/tests/test_isort.py index e4632f41..8b6ae620 100644 --- a/tests/test_isort.py +++ b/tests/test_isort.py @@ -2922,6 +2922,7 @@ def test_to_ensure_importing_from_imports_module_works_issue_662() -> None: "@wraps(fun)\n" "def __inner(*args, **kwargs):\n" " from .imports import qualname\n" + "\n" " warn(description=description or qualname(fun), deprecation=deprecation, " "removal=removal)\n" ) @@ -4158,3 +4159,31 @@ def test_isort_with_single_character_import() -> None: """ test_input = "from django.db.models import CASCADE, SET_NULL, Q\n" assert SortImports(file_contents=test_input).output == test_input + + +def test_isort_nested_imports() -> None: + """Ensure imports in a nested block get sorted correctly""" + test_input = """ + def import_test(): + import sys + import os + + # my imports + from . import def + from . import abc + + return True + """ + assert ( + SortImports(file_contents=test_input).output + == """ + def import_test(): + import os + import sys + + # my imports + from . import abc, def + + return True + """ + ) |
