summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Crosley <timothy.crosley@gmail.com>2019-02-28 01:38:30 -0800
committerTimothy Crosley <timothy.crosley@gmail.com>2019-02-28 01:38:30 -0800
commit1492706314dd710a85cbd8602eabd92da082fcc5 (patch)
tree37d4cd294be610c03d76d3f6322a750f0ee844c8
parentf8cce6901fbc7a9b296962157fec6c04c448ae2a (diff)
downloadisort-1492706314dd710a85cbd8602eabd92da082fcc5.tar.gz
Better settings management for tests cross OS
-rw-r--r--test_isort.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/test_isort.py b/test_isort.py
index ddfdb772..40c62e38 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -55,6 +55,11 @@ skip = build,.tox,venv
balanced_wrapping = true
not_skip = __init__.py
"""
+TEST_SETTINGS_DICT = {'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"
@@ -569,8 +574,9 @@ def test_skip_with_file_name():
test_input = ("import django\n"
"import myproject\n")
- sort_imports = SortImports(file_path='/baz.py', file_contents=test_input, known_third_party=['django'],
- skip=['baz.py'])
+ my_sort_settings = TEST_SETTINGS_DICT.copy()
+ my_sort_settings['skip'] = ['baz.py']
+ sort_imports = SortImports(file_path='/baz.py', file_contents=test_input, **my_sort_settings)
assert sort_imports.skipped
assert sort_imports.output is None
@@ -1725,7 +1731,7 @@ def test_other_file_encodings(tmpdir):
tmp_fname = tmpdir.join('test_{0}.py'.format(encoding))
file_contents = "# coding: {0}\n\ns = u'ã'\n".format(encoding)
tmp_fname.write_binary(file_contents.encode(encoding))
- assert SortImports(file_path=str(tmp_fname)).output == file_contents
+ assert SortImports(file_path=str(tmp_fname), **TEST_SETTINGS_DICT).output == file_contents
def test_comment_at_top_of_file():
@@ -2520,7 +2526,7 @@ def test_new_lines_are_preserved():
with io.open(rn_newline.name, mode='w', newline='') as rn_newline_input:
rn_newline_input.write('import sys\r\nimport os\r\n')
- SortImports(rn_newline.name)
+ SortImports(rn_newline.name, **TEST_SETTINGS_DICT)
with io.open(rn_newline.name, newline='') as rn_newline_file:
rn_newline_contents = rn_newline_file.read()
assert rn_newline_contents == 'import os\r\nimport sys\r\n'
@@ -2534,7 +2540,7 @@ def test_new_lines_are_preserved():
with io.open(r_newline.name, mode='w', newline='') as r_newline_input:
r_newline_input.write('import sys\rimport os\r')
- SortImports(r_newline.name)
+ SortImports(r_newline.name, **TEST_SETTINGS_DICT)
with io.open(r_newline.name, newline='') as r_newline_file:
r_newline_contents = r_newline_file.read()
assert r_newline_contents == 'import os\rimport sys\r'
@@ -2548,7 +2554,7 @@ def test_new_lines_are_preserved():
with io.open(n_newline.name, mode='w', newline='') as n_newline_input:
n_newline_input.write('import sys\nimport os\n')
- SortImports(n_newline.name)
+ SortImports(n_newline.name, **TEST_SETTINGS_DICT)
with io.open(n_newline.name, newline='') as n_newline_file:
n_newline_contents = n_newline_file.read()
assert n_newline_contents == 'import os\nimport sys\n'