summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2019-04-09 21:08:19 -0700
committerTimothy Crosley <timothy.crosley@gmail.com>2019-04-09 21:08:19 -0700
commitec17180914d65b95a0666c26cb428871b792e267 (patch)
tree6d098b3636fb1057dddaed4e010657a55d8c8bde
parent7e67f4abc77ff921e38d902610336241452805ac (diff)
downloadisort-feature/fix-issue-691.tar.gz
Add test case for issue #691feature/fix-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