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__changes_uncovered_but_with_better_coverage_exit_status():
from pycobertura.cli import diff, ExitCodes
runner = CliRunner()
result = runner.invoke(diff, [
'tests/dummy.zeroexit1/coverage.xml',
'tests/dummy.zeroexit2/coverage.xml', # has uncovered changes
], catch_exceptions=False)
assert result.exit_code == ExitCodes.NOT_ALL_CHANGES_COVERED
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