summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2020-02-13 14:22:28 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2020-02-13 14:22:28 -0800
commit8ba2707de62f93141e789c15af89c999b5466779 (patch)
tree64a4fb5ed70f3392eb856f98907538ac06015af3
parenta06e3d30ca6a089068f108f927407c0068c43930 (diff)
downloadisort-issue/1005-python-future.tar.gz
Test confirming issue #1005 is fixedissue/1005-python-future
-rw-r--r--tests/test_isort.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/test_isort.py b/tests/test_isort.py
index 4aadcc9e..d6781eac 100644
--- a/tests/test_isort.py
+++ b/tests/test_isort.py
@@ -4971,3 +4971,74 @@ from package2 import \\
SortImports(file_contents=test_input, line_length=25, multi_line_output=2).output
== expected_output
)
+
+
+def test_python_future_category():
+ """Test to ensure a manual python future category will work as needed to install aliases
+
+ see: Issue #1005
+ """
+ test_input = """from __future__ import absolute_import
+
+from future import standard_library
+
+standard_library.install_aliases()
+
+import os
+import re
+import time
+
+from logging.handlers import SysLogHandler
+
+from builtins import len, object, str
+
+from katlogger import log_formatter, log_rollover
+
+from .query_elastic import QueryElastic
+"""
+ expected_output = """from __future__ import absolute_import
+
+from future import standard_library
+
+standard_library.install_aliases()
+
+# Python Standard Library
+import os
+import re
+import time
+
+from builtins import len, object, str
+from logging.handlers import SysLogHandler
+
+# CAM Packages
+from katlogger import log_formatter, log_rollover
+
+# Explicitly Local
+from .query_elastic import QueryElastic
+"""
+ assert (
+ SortImports(
+ file_contents=test_input,
+ force_grid_wrap=False,
+ include_trailing_comma=True,
+ indent=4,
+ line_length=90,
+ multi_line_output=3,
+ lines_between_types=1,
+ sections=[
+ "FUTURE_LIBRARY",
+ "FUTURE_THIRDPARTY",
+ "STDLIB",
+ "THIRDPARTY",
+ "FIRSTPARTY",
+ "LOCALFOLDER",
+ ],
+ import_heading_stdlib="Python Standard Library",
+ import_heading_thirdparty="Third Library",
+ import_heading_firstparty="CAM Packages",
+ import_heading_localfolder="Explicitly Local",
+ known_first_party=["katlogger"],
+ known_future_thirdparty=["future"],
+ ).output
+ == expected_output
+ )