From ec17180914d65b95a0666c26cb428871b792e267 Mon Sep 17 00:00:00 2001 From: Timothy Crosley Date: Tue, 9 Apr 2019 21:08:19 -0700 Subject: Add test case for issue #691 --- test_isort.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 -- cgit v1.2.1