Skip to content

More tolerant in certain circumstances where report generation was failed #161

@huyphan

Description

@huyphan

Back in version 2.2.1 we were more tolerant when something went wrong with coverage report generation:

        if not (self.failed and self.options.no_cov_on_fail):
            try:
                total = self.cov_controller.summary(terminalreporter.writer)
            except CoverageException as exc:
                terminalreporter.writer.write('Failed to generate report: %s\n' % exc)
                total = 0

With 2.5.1, we raise exception instead:

        if not self._is_slave(session) and self._should_report():
            try:
                self.cov_total = self.cov_controller.summary(self.cov_report)
            except CoverageException as exc:
                raise pytest.UsageError(
                    'Failed to generate report: %s\n' % exc
                )
            assert self.cov_total is not None, 'Test coverage should never be `None`'

Do you think it would make sense if we make it to be tolerant like the old days? I'm having some projects that are built on multiple Python implementations with the same code base. One of the implementation (Jython) doesn't support code coverage and will cause CoverageException. If we re-raise the exception here, the whole test will fail.

I can send a PR for this, but I would like to get some opinions first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions