diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2019-03-07 08:42:41 -0800 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2019-03-07 23:19:03 -0800 |
commit | 92d26b1087ae0255aa076cb09a3ea07a47c65928 (patch) | |
tree | d130c7942f98269a035f1b45b7c483d2703e5850 | |
parent | 169029f33e9ee9477d266a6a172df3f9b79bff8e (diff) | |
download | isort-92d26b1087ae0255aa076cb09a3ea07a47c65928.tar.gz |
Add first additional test case
-rw-r--r-- | test_isort.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/test_isort.py b/test_isort.py index 999f1a1e..00e7e82e 100644 --- a/test_isort.py +++ b/test_isort.py @@ -2743,13 +2743,16 @@ def test_command_line(tmpdir, capfd, multiprocess): @pytest.mark.parametrize('enabled', (False, True)) def test_safety_excludes(tmpdir, enabled): tmpdir.join("victim.py").write("# ...") - tmpdir.mkdir(".tox").join("verysafe.py").write("# ...") + toxdir = tmpdir.mkdir(".tox") + toxdir.join("verysafe.py").write("# ...") tmpdir.mkdir("lib").mkdir("python3.7").join("importantsystemlibrary.py").write("# ...") tmpdir.mkdir(".pants.d").join("pants.py").write("import os") config = dict(settings.default.copy(), safety_excludes=enabled) skipped = [] codes = [str(tmpdir)], main.iter_source_code(codes, config, skipped) + + # if enabled files within nested unsafe directories should be skipped file_names = set(os.path.relpath(f, str(tmpdir)) for f in main.iter_source_code([str(tmpdir)], config, skipped)) if enabled: assert file_names == {'victim.py'} @@ -2761,6 +2764,10 @@ def test_safety_excludes(tmpdir, enabled): 'victim.py'} assert not skipped + # directly pointing to files within unsafe directories shouldn't skip them either way + file_names = set(os.path.relpath(f, str(toxdir)) for f in main.iter_source_code([str(toxdir)], config, skipped)) + assert file_names == {'verysafe.py'} + def test_comments_not_removed_issue_576(): test_input = ('import distutils\n' |