mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-08 22:04:17 +00:00
Merge branch 'fix/exit-zero' into 'master'
Fix --exit-zero when --diff is empty See merge request pycqa/flake8!391
This commit is contained in:
commit
5c2b881232
2 changed files with 7 additions and 18 deletions
|
|
@ -124,7 +124,9 @@ class Application(object):
|
||||||
if self.options.count:
|
if self.options.count:
|
||||||
print(self.result_count)
|
print(self.result_count)
|
||||||
|
|
||||||
if not self.options.exit_zero:
|
if self.options.exit_zero:
|
||||||
|
raise SystemExit(self.catastrophic_failure)
|
||||||
|
else:
|
||||||
raise SystemExit(
|
raise SystemExit(
|
||||||
(self.result_count > 0) or self.catastrophic_failure
|
(self.result_count > 0) or self.catastrophic_failure
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -23,29 +23,16 @@ def application():
|
||||||
return app.Application()
|
return app.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(
|
@pytest.mark.parametrize(
|
||||||
'result_count, catastrophic, exit_zero, value', [
|
'result_count, catastrophic, exit_zero, value', [
|
||||||
(0, False, False, False),
|
(0, False, False, False),
|
||||||
(0, True, False, True),
|
(0, True, False, True),
|
||||||
(2, False, False, True),
|
(2, False, False, True),
|
||||||
(2, True, 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,
|
def test_exit_does_raise(result_count, catastrophic, exit_zero, value,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue