-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1274 from timothycrosley/issue/1264
Issue/1264
- Loading branch information
Showing
4 changed files
with
64 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""A growing set of tests designed to ensure isort doesn't have regressions in new versions""" | ||
import isort | ||
|
||
|
||
def test_isort_duplicating_comments_issue_1264(): | ||
"""Ensure isort doesn't duplicate comments when force_sort_within_sections is set to `True` | ||
as was the case in issue #1264: https://github.com/timothycrosley/isort/issues/1264 | ||
""" | ||
assert ( | ||
isort.code( | ||
""" | ||
from homeassistant.util.logging import catch_log_exception | ||
# Loading the config flow... | ||
from . import config_flow | ||
""", | ||
force_sort_within_sections=True, | ||
).count("# Loading the config flow...") | ||
== 1 | ||
) | ||
|
||
|
||
def test_moving_comments_issue_726(): | ||
test_input = ( | ||
"from Blue import models as BlueModels\n" | ||
"# comment for PlaidModel\n" | ||
"from Plaid.models import PlaidModel\n" | ||
) | ||
assert isort.code(test_input, force_sort_within_sections=True) == test_input | ||
|
||
test_input = ( | ||
"# comment for BlueModels\n" | ||
"from Blue import models as BlueModels\n" | ||
"# comment for PlaidModel\n" | ||
"# another comment for PlaidModel\n" | ||
"from Plaid.models import PlaidModel\n" | ||
) | ||
assert isort.code(test_input, force_sort_within_sections=True) == test_input |