diff options
author | Timothy Crosley <timothy.crosley@gmail.com> | 2021-04-01 20:43:32 -0700 |
---|---|---|
committer | Timothy Crosley <timothy.crosley@gmail.com> | 2021-04-01 20:43:32 -0700 |
commit | 27606a9143aa9643908a8f02b8a06187dbd96928 (patch) | |
tree | 9b48a1a48952d6be89ac6c0bf251dfc0d0e40c11 | |
parent | 3896dae9df9fb084634763f62485d7cd5808c2b2 (diff) | |
parent | 48fe2397577a05bee734ff8196b37ef073aa8ea1 (diff) | |
download | isort-27606a9143aa9643908a8f02b8a06187dbd96928.tar.gz |
Merge branch 'main' of https://github.com/timothycrosley/isort into main
-rw-r--r-- | isort/files.py | 2 | ||||
-rw-r--r-- | tests/unit/test_main.py | 22 |
2 files changed, 22 insertions, 2 deletions
diff --git a/isort/files.py b/isort/files.py index 692c2011..313d16b7 100644 --- a/isort/files.py +++ b/isort/files.py @@ -34,7 +34,7 @@ def find( for filename in filenames: filepath = os.path.join(dirpath, filename) if config.is_supported_filetype(filepath): - if config.is_skipped(Path(filepath)): + if config.is_skipped(Path(os.path.abspath(filepath))): skipped.append(filename) else: yield filepath diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 86f62db3..581b3a56 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -1,4 +1,5 @@ import json +import os import subprocess from datetime import datetime from io import BytesIO, TextIOWrapper @@ -352,7 +353,26 @@ import b assert "Skipped" not in out main.main([str(python_file), "--skip-gitignore", "--filter-files"]) out, error = capsys.readouterr() - assert "Skipped" in out + assert "Skipped" in out and "has_imports.py" not in out + + tmpdir.join(".gitignore").remove() + + currentdir = os.getcwd() + os.chdir(tmpdir) + + tmpdir.join(".gitignore").write("nested_dir/has_imports.py") + subpython_file = tmpdir.join("nested_dir/has_imports.py") + subpython_file.write( + """ +import b +import a +""" + ) + main.main([".", "--skip-gitignore", "--filter-files"]) + out, error = capsys.readouterr() + assert "nested_dir/has_imports.py" not in out + + os.chdir(currentdir) # warnings should be displayed if old flags are used with pytest.warns(UserWarning): |