Skip to content

Pytest marker conditional coverage ? #45

@davidwaroquiers

Description

@davidwaroquiers

Dear developers of the coverage-conditional-plugin,

First, thank you for this nice plugin! It really makes a plus to tune our test suites!

I wanted to know if there was a way to make a "pytest marker"-based conditional coverage. Supposing I have defined a bunch of markers, e.g. "slow", "fast", "basic" and "extended", is it possible to define a conditional pragma based on the current pytest's "MARKEXPR".

That is, if you issue "pytest -m slow" for example, a line with something like "# pragma: no-cover-if-slow" would not be counted in the coverage. I guess this would need something like a special pragma-condition (something "similar" to the "is_installed" expression) for determining whether we are in the "right" marker. A set of rules could then be something like:

rules =
"pytest_runs_with_marker('slow')": no-cover-if-slow
...

Even better, could this be figured out at run time instead of "hard"-coded in the rules ?

But maybe there is another way or it is already possible ?

Any idea ?

Thanks a lot,

David

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