summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-12-02 06:25:27 +0000
committerAnthony Sottile <asottile@umich.edu>2019-12-02 06:25:27 +0000
commit1062be2643421797ea602f121d51c2b070e1cf18 (patch)
tree079473bb4c3a420ceeca4df842bfdd65e5fe52ac
parentd99fd24ec520524b44ec92579c7178084ce2dc90 (diff)
parentcc037338df79df6a1d693d70113033aac355cd77 (diff)
downloadflake8-1062be2643421797ea602f121d51c2b070e1cf18.tar.gz
Merge branch 'fix/exit-zero' into 'master'
Fix --exit-zero when --diff is empty See merge request pycqa/flake8!391
-rw-r--r--src/flake8/main/application.py4
-rw-r--r--tests/unit/test_application.py21
2 files changed, 7 insertions, 18 deletions
diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py
index a20c1d4..e8e63b9 100644
--- a/src/flake8/main/application.py
+++ b/src/flake8/main/application.py
@@ -124,7 +124,9 @@ class Application(object):
if self.options.count:
print(self.result_count)
- if not self.options.exit_zero:
+ if self.options.exit_zero:
+ raise SystemExit(self.catastrophic_failure)
+ else:
raise SystemExit(
(self.result_count > 0) or self.catastrophic_failure
)
diff --git a/tests/unit/test_application.py b/tests/unit/test_application.py
index 04845a4..51adefb 100644
--- a/tests/unit/test_application.py
+++ b/tests/unit/test_application.py
@@ -24,28 +24,15 @@ def application():
@pytest.mark.parametrize(
- 'result_count, catastrophic, exit_zero', [
- (0, True, True),
- (2, False, True),
- (2, True, True),
- ]
-)
-def test_exit_does_not_raise(result_count, catastrophic, exit_zero,
- application):
- """Verify Application.exit doesn't raise SystemExit."""
- application.result_count = result_count
- application.catastrophic_failure = catastrophic
- application.options = options(exit_zero=exit_zero)
-
- assert application.exit() is None
-
-
-@pytest.mark.parametrize(
'result_count, catastrophic, exit_zero, value', [
(0, False, False, False),
(0, True, False, True),
(2, False, False, True),
(2, True, False, True),
+
+ (0, True, True, True),
+ (2, False, True, False),
+ (2, True, True, True),
]
)
def test_exit_does_raise(result_count, catastrophic, exit_zero, value,