Skip to content

Commit

Permalink
pytest-cov no longer populates cov_total when there is no report
Browse files Browse the repository at this point in the history
We no longer skip when `cov_total` is `None`, but we put an additional
guard in when we generate the XML report, so we catch potential errors
there instead.
  • Loading branch information
Daverball committed Aug 21, 2024
1 parent 4511faf commit 6c068d8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/pytest_codecov/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,19 @@ def upload_report(self, terminalreporter, config, cov):
token=config.option.codecov_token,
)
uploader.write_network_files(git.ls_files())
uploader.add_coverage_report(cov)
from coverage.misc import CoverageException
try:
uploader.add_coverage_report(cov)
except CoverageException as exc:
terminalreporter.section('Codecov.io payload')
terminalreporter.write_line(
f'ERROR: Failed to generate XML report: {exc}',
red=True,
bold=True,
)
terminalreporter.line('')
return

if config.option.codecov_dump:
terminalreporter.section('Prepared Codecov.io payload')
terminalreporter.write_line(uploader.get_payload())
Expand Down Expand Up @@ -155,9 +167,6 @@ def pytest_terminal_summary(self, terminalreporter, exitstatus, config):
if cov_plugin.cov_controller is None:
return

if cov_plugin.cov_total is None:
return

cov = cov_plugin.cov_controller.cov
if cov is None:
return
Expand Down

0 comments on commit 6c068d8

Please sign in to comment.