summaryrefslogtreecommitdiff
path: root/test_isort.py
diff options
context:
space:
mode:
authorTimothy Edmund Crosley <timothy.crosley@gmail.com>2019-03-23 22:31:52 -0700
committerTimothy Crosley <timothy.crosley@gmail.com>2019-03-24 18:18:26 -0700
commit36b6b24afbf058f108e518ee1e7ded3f933d3b2e (patch)
tree33f82fa96f65cc48b633ebe27b219a7aa81f0392 /test_isort.py
parentb532f31be4f4f027bce29fcef3c7952bc0e04b50 (diff)
downloadisort-36b6b24afbf058f108e518ee1e7ded3f933d3b2e.tar.gz
Merge pull request #911 from timothycrosley/feature/fix-issue-909
Feature/fix issue 909
Diffstat (limited to 'test_isort.py')
-rw-r--r--test_isort.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/test_isort.py b/test_isort.py
index 91cb6f10..a729139b 100644
--- a/test_isort.py
+++ b/test_isort.py
@@ -20,22 +20,23 @@ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT
OTHER DEALINGS IN THE SOFTWARE.
"""
-from tempfile import NamedTemporaryFile
import io
import os
import os.path
import posixpath
import sys
import sysconfig
+from subprocess import check_output
+from tempfile import NamedTemporaryFile
import py
import pytest
from isort import finders, main, settings
from isort.isort import SortImports
-from isort.utils import exists_case_sensitive
from isort.main import is_python_file
from isort.settings import WrapModes
+from isort.utils import exists_case_sensitive
try:
import toml
@@ -2930,3 +2931,33 @@ def test_standard_library_deprecates_user_issue_778():
'\n'
'import user\n')
assert SortImports(file_contents=test_input).output == test_input
+
+
+def test_settings_path_skip_issue_909(tmpdir):
+ base_dir = tmpdir.mkdir('project')
+ config_dir = base_dir.mkdir('conf')
+ config_dir.join('.isort.cfg').write('[isort]\n'
+ 'skip =\n'
+ ' file_to_be_skipped.py\n'
+ 'skip_glob =\n'
+ ' *glob_skip*\n')
+
+ base_dir.join('file_glob_skip.py').write('import os\n'
+ '\n'
+ 'print("Hello World")\n'
+ '\n'
+ 'import sys\n')
+ base_dir.join('file_to_be_skipped.py').write('import os\n'
+ '\n'
+ 'print("Hello World")'
+ '\n'
+ 'import sys\n')
+
+ test_run_directory = os.getcwd()
+ os.chdir(str(base_dir))
+ with pytest.raises(Exception): # without the settings path provided: the command should not skip & identify errors
+ check_output(['isort', '--check-only'])
+ results = check_output(['isort', '--check-only', '--settings-path=conf/.isort.cfg'])
+ os.chdir(str(test_run_directory))
+
+ assert b'skipped 2' in results.lower()