Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pytest marker conditional coverage ? #45

Open
davidwaroquiers opened this issue Dec 9, 2020 · 1 comment
Open

Pytest marker conditional coverage ? #45

davidwaroquiers opened this issue Dec 9, 2020 · 1 comment

Comments

@davidwaroquiers
Copy link

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

@sobolevn
Copy link
Member

sobolevn commented Dec 9, 2020

It is not possible at the moment I guess.

But, a PR with the support of the following feature would make sense! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants