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__worse_coverage_exit_status():
from pycobertura.cli import diff, ExitCodes
runner = CliRunner()
result = runner.invoke(diff, [
'tests/dummy.with-dummy2-no-cov.xml',
'tests/dummy.with-dummy2-better-and-worse.xml', # has covered AND uncovered lines
'--no-source',
], catch_exceptions=False)
assert result.exit_code == ExitCodes.COVERAGE_WORSENED
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