diff options
| author | jasonbrackman <brackman@gmail.com> | 2018-01-24 14:57:03 -0800 |
|---|---|---|
| committer | jasonbrackman <brackman@gmail.com> | 2018-01-24 14:57:03 -0800 |
| commit | 675dc98dd00521a5eb56539ba0108e696b79cb6b (patch) | |
| tree | 5bcd09cb1cd64659663a8b89885dc5eb89154fd2 /test_isort.py | |
| parent | 0def146e29572590e1301403b13366919cb791da (diff) | |
| download | isort-675dc98dd00521a5eb56539ba0108e696b79cb6b.tar.gz | |
added a test for imports created at load time, such as six.moves.
simplified test of import beinga module or package.
** forgot a file.
Diffstat (limited to 'test_isort.py')
| -rw-r--r-- | test_isort.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test_isort.py b/test_isort.py index 496339c1..c0c96207 100644 --- a/test_isort.py +++ b/test_isort.py @@ -2284,3 +2284,27 @@ def test_no_inline_sort(): ) 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 + + +def test_relative_import_of_a_module(): + """Imports can be dynamically created (PEP302) and is used by modules such as six. This test ensures that + these types of imports are still sorted to the correct type instead of being categorized as local.""" + test_input = ('from __future__ import absolute_import\n' + '\n' + 'import itertools\n' + '\n' + 'from six import add_metaclass\n' + '\n' + 'from six.moves import asd\n' + ) + + expected_results = ('from __future__ import absolute_import\n' + '\n' + 'import itertools\n' + '\n' + 'from six import add_metaclass\n' + 'from six.moves import asd\n' + ) + + sorted_result = SortImports(file_contents=test_input, force_single_line=True).output + assert sorted_result == expected_results |
