Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_diff__better_coverage_has_exit_status_of_zero():
from pycobertura.cli import diff, ExitCodes
runner = CliRunner()
result = runner.invoke(diff, [
'tests/dummy.original.xml',
'tests/dummy.original-full-cov.xml', # has no uncovered lines
'--no-source',
], catch_exceptions=False)
assert result.exit_code == ExitCodes.OK
def get_exit_code(differ, source):
# Compute the non-zero exit code. This is a 2-step process which involves
# checking whether code coverage is any better first and then check if all
# changes are covered (stricter) which can only be done if the source code
# is available (and enabled via the --source option).
if not differ.has_better_coverage():
return ExitCodes.COVERAGE_WORSENED
if source:
if differ.has_all_changes_covered():
return ExitCodes.OK
else:
return ExitCodes.NOT_ALL_CHANGES_COVERED
else:
return ExitCodes.OK
def get_exit_code(differ, source):
# Compute the non-zero exit code. This is a 2-step process which involves
# checking whether code coverage is any better first and then check if all
# changes are covered (stricter) which can only be done if the source code
# is available (and enabled via the --source option).
if not differ.has_better_coverage():
return ExitCodes.COVERAGE_WORSENED
if source:
if differ.has_all_changes_covered():
return ExitCodes.OK
else:
return ExitCodes.NOT_ALL_CHANGES_COVERED
else:
return ExitCodes.OK