summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/isort.py2
-rw-r--r--test_isort.py19
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