Skip to content

Commit

Permalink
Merge pull request #24 from cas--/Issue/22/ForceSingleLine
Browse files Browse the repository at this point in the history
Fix #23: Invalid warnings with force_single_line enabled
  • Loading branch information
gforcada committed Nov 25, 2016
2 parents 3ea8110 + 7805ecf commit 52ffb99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake8_isort.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def _fixup_sortimports_wrapped(sort_imports):
isort.SortImports: The modified isort results object.
"""
for idx, line in enumerate(sort_imports.out_lines):
if '\n ' in line:
if '\n' in line:
for new_idx, new_line in enumerate(
sort_imports.out_lines.pop(idx).splitlines()):
sort_imports.out_lines.insert(idx + new_idx, new_line)
11 changes: 11 additions & 0 deletions run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ def test_wrapped_imports(self):
ret = list(checker.run())
self.assertEqual(ret, [])

def test_force_single_line_imports(self):
file_path = self._given_a_file_in_test_dir(
'from plone.app.testing import applyProfile\n'
'from plone.app.testing import FunctionalTesting\n',
isort_config='force_alphabetical_sort=True\nforce_single_line=True'
)
with OutputCapture():
checker = Flake8Isort(None, file_path)
ret = list(checker.run())
self.assertEqual(ret, [])

def test_isortcfg_found(self):
# _given_a_file_in_test_dir already creates an .isort.cfg file
file_path = self._given_a_file_in_test_dir(
Expand Down

0 comments on commit 52ffb99

Please sign in to comment.