diff options
author | Timothy Edmund Crosley <timothy.crosley@gmail.com> | 2019-03-06 19:05:48 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 19:05:48 -0800 |
commit | d8a0960a0cb2f99b096f8f53ac2198317b93fad6 (patch) | |
tree | 6d9a946f660476623d5366fe43e1f3c476674954 | |
parent | 0a64cc1b7c57c77dbcd9854ef51fb1ecf4b53063 (diff) | |
parent | 30ec3d0b4fa84a985a4226fb92700f8bb36c4f94 (diff) | |
download | isort-d8a0960a0cb2f99b096f8f53ac2198317b93fad6.tar.gz |
Merge pull request #884 from emilmelnikov/patch-1
Do not print file names when in the quiet mode
-rw-r--r-- | isort/isort.py | 3 | ||||
-rw-r--r-- | test_isort.py | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/isort/isort.py b/isort/isort.py index 73363e83..0d8d6f09 100644 --- a/isort/isort.py +++ b/isort/isort.py @@ -212,7 +212,8 @@ class SortImports(object): if answer in ('quit', 'q'): sys.exit(1) with open(self.file_path, 'w', encoding=self.file_encoding, newline='') as output_file: - print("Fixing {0}".format(self.file_path)) + if not self.config['quiet']: + print("Fixing {0}".format(self.file_path)) output_file.write(self.output) @property diff --git a/test_isort.py b/test_isort.py index 999f1a1e..bfc89ff9 100644 --- a/test_isort.py +++ b/test_isort.py @@ -2740,6 +2740,22 @@ def test_command_line(tmpdir, capfd, multiprocess): assert str(tmpdir.join("file2.py")) in out +@pytest.mark.parametrize("quiet", (False, True)) +def test_quiet(tmpdir, capfd, quiet): + if sys.platform.startswith("win"): + return + from isort.main import main + tmpdir.join("file1.py").write("import re\nimport os") + tmpdir.join("file2.py").write("") + arguments = ["-rc", str(tmpdir)] + if quiet: + arguments.append("-q") + main(arguments) + out, err = capfd.readouterr() + assert not err + assert bool(out) != quiet + + @pytest.mark.parametrize('enabled', (False, True)) def test_safety_excludes(tmpdir, enabled): tmpdir.join("victim.py").write("# ...") |