diff options
author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2019-04-05 20:45:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-05 20:45:54 -0700 |
commit | c46766433a36ba8a4f8f239ef57adde7cda52732 (patch) | |
tree | 0f75ebe500f9366c86a2413bc986b3fde48210ad | |
parent | 3dbbc6b01d6cfc9a133a95ad9438425cd635377e (diff) | |
parent | cbf6ba7a1fcdf5ac7492adb2137bd646f9a27d81 (diff) | |
download | isort-c46766433a36ba8a4f8f239ef57adde7cda52732.tar.gz |
Merge pull request #917 from timothycrosley/feature/fix-issue-916
Feature/fix issue 916
-rw-r--r-- | isort/isort.py | 2 | ||||
-rw-r--r-- | test_isort.py | 19 |
2 files changed, 20 insertions, 1 deletions
diff --git a/isort/isort.py b/isort/isort.py index 5757c009..7609648e 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -884,7 +884,7 @@ class SortImports(object): self._in_top_comment = True return True elif self._in_top_comment: - if not line.startswith("#"): + if not line.startswith("#") or line in self._section_comments: self._in_top_comment = False self._first_comment_index_end = self.index - 1 diff --git a/test_isort.py b/test_isort.py index a729139b..7c42e84c 100644 --- a/test_isort.py +++ b/test_isort.py @@ -2961,3 +2961,22 @@ def test_settings_path_skip_issue_909(tmpdir): os.chdir(str(test_run_directory)) assert b'skipped 2' in results.lower() + + +def test_failing_file_check_916(): + test_input = ('#!/usr/bin/env python\n' + '# -*- coding: utf-8 -*-\n' + 'from __future__ import unicode_literals\n') + expected_output = ('#!/usr/bin/env python\n' + '# -*- coding: utf-8 -*-\n' + '# FUTURE\n' + 'from __future__ import unicode_literals\n') + settings = {'known_future_library': 'future', + 'import_heading_future': 'FUTURE', + 'sections': ['FUTURE', 'STDLIB', 'NORDIGEN', 'FIRSTPARTY', 'THIRDPARTY', 'LOCALFOLDER'], + 'indent': ' ', + 'multi_line_output': 3, + 'lines_after_imports': 2} + assert SortImports(file_contents=test_input, **settings).output == expected_output + assert SortImports(file_contents=expected_output, **settings).output == expected_output + assert not SortImports(file_contents=expected_output, check=True, **settings).incorrectly_sorted |