diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2019-02-23 17:26:01 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2019-02-23 17:26:01 -0800 |
commit | 93982676faa249f069344be4700af6fda4a54eaa (patch) | |
tree | 94b6c0511106cfac917bf952773428aadeadd6d9 | |
parent | 7e4909665b611798e370d1466d64ef137c89dc22 (diff) | |
download | isort-93982676faa249f069344be4700af6fda4a54eaa.tar.gz |
Try to include config in test suite by default
-rw-r--r-- | test_isort.py | 29 | ||||
-rw-r--r-- | testing/.isort.cfg | 10 | ||||
-rw-r--r-- | testing/my_file.py | 2 | ||||
-rw-r--r-- | testing/my_file2.py | 5 |
4 files changed, 42 insertions, 4 deletions
diff --git a/test_isort.py b/test_isort.py index e2320295..8ea07636 100644 --- a/test_isort.py +++ b/test_isort.py @@ -25,6 +25,7 @@ from __future__ import absolute_import, division, print_function, unicode_litera from tempfile import NamedTemporaryFile import io +import os import os.path import sys import sysconfig @@ -43,12 +44,22 @@ try: except ImportError: toml = None -SHORT_IMPORT = "from third_party import lib1, lib2, lib3, lib4" +TEST_DEFAULT_CONFIG = """ +[*.py] +max_line_length = 120 +indent_style = space +indent_size = 4 +known_first_party = isort +known_third_party = kate +ignore_frosted_errors = E103 +skip = build,.tox,venv +balanced_wrapping = true +not_skip = __init__.py +""" +SHORT_IMPORT = "from third_party import lib1, lib2, lib3, lib4" SINGLE_FROM_IMPORT = "from third_party import lib1" - SINGLE_LINE_LONG_IMPORT = "from third_party import lib1, lib2, lib3, lib4, lib5, lib5ab" - REALLY_LONG_IMPORT = ("from third_party import lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, lib10, lib11," "lib12, lib13, lib14, lib15, lib16, lib17, lib18, lib20, lib21, lib22") REALLY_LONG_IMPORT_WITH_COMMENT = ("from third_party import lib1, lib2, lib3, lib4, lib5, lib6, lib7, lib8, lib9, " @@ -56,6 +67,16 @@ REALLY_LONG_IMPORT_WITH_COMMENT = ("from third_party import lib1, lib2, lib3, li " # comment") +@pytest.fixture(scope="session", autouse=True) +def default_settings_path(tmpdir_factory): + config_dir = tmpdir_factory.mktemp('config') + config_file = config_dir.join('.editorconfig') + with open(config_file, 'w') as editorconfig: + editorconfig.write(TEST_DEFAULT_CONFIG) + os.chdir(config_dir) + return str(config_dir) + + def test_happy_path(): """Test the most basic use case, straight imports no code, simply not organized by category.""" test_input = ("import sys\n" @@ -842,7 +863,7 @@ def test_known_pattern_path_expansion(): test_output = SortImports( file_contents=test_input, default_section='THIRDPARTY', - known_first_party=['./', 'this'] + known_first_party=['./', 'this', 'kate_plugin'] ).output if PY2: assert test_output == ("import os\n" diff --git a/testing/.isort.cfg b/testing/.isort.cfg new file mode 100644 index 00000000..7e04dd75 --- /dev/null +++ b/testing/.isort.cfg @@ -0,0 +1,10 @@ +# [settings] +# multi_line_output=6 +# line_length=40 +[settings] +multi_line_output=3 +include_trailing_comma=True +force_grid_wrap=0 +combine_as_imports=True +line_length=88 +force_sort_within_sections=True diff --git a/testing/my_file.py b/testing/my_file.py new file mode 100644 index 00000000..1fead13c --- /dev/null +++ b/testing/my_file.py @@ -0,0 +1,2 @@ +from veryveryveryveryveryvery import big +from veryveryveryveryveryvery import small diff --git a/testing/my_file2.py b/testing/my_file2.py new file mode 100644 index 00000000..b5a9465c --- /dev/null +++ b/testing/my_file2.py @@ -0,0 +1,5 @@ +import cv2 +import gym +from gym import spaces +import numpy +import pygame |