summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Edmund Crosley <timothy.crosley@gmail.com>2019-04-09 21:23:34 -0700
committerGitHub <noreply@github.com>2019-04-09 21:23:34 -0700
commit596692c0421aea6aa22c77e659615f6bf67ff853 (patch)
tree6d098b3636fb1057dddaed4e010657a55d8c8bde
parent7e67f4abc77ff921e38d902610336241452805ac (diff)
parentec17180914d65b95a0666c26cb428871b792e267 (diff)
downloadisort-596692c0421aea6aa22c77e659615f6bf67ff853.tar.gz
Merge pull request #921 from timothycrosley/feature/fix-issue-691
Add test case for issue #691
-rw-r--r--test_isort.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test_isort.py b/test_isort.py
index 444b6c3b..92c6d197 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -2997,3 +2997,26 @@ def test_import_heading_issue_905():
'# Local imports\n'
'from oklib.plot_ok import imagesc\n')
assert SortImports(file_contents=test_input, **config).output == test_input
+
+
+def test_isort_keeps_comments_issue_691():
+ test_input = ('import os\n'
+ '# This will make sure the app is always imported when\n'
+ '# Django starts so that shared_task will use this app.\n'
+ 'from .celery import app as celery_app # noqa\n'
+ '\n'
+ 'PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))\n'
+ '\n'
+ 'def path(*subdirectories):\n'
+ ' return os.path.join(PROJECT_DIR, *subdirectories)\n')
+ expected_output = ('import os\n'
+ '\n'
+ '# This will make sure the app is always imported when\n'
+ '# Django starts so that shared_task will use this app.\n'
+ 'from .celery import app as celery_app # noqa\n'
+ '\n'
+ 'PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))\n'
+ '\n'
+ 'def path(*subdirectories):\n'
+ ' return os.path.join(PROJECT_DIR, *subdirectories)\n')
+ assert SortImports(file_contents=test_input).output == expected_output