Description
I just tried to use coverage-conditional-plugin
by following the README, however pytest-cov was still reporting less than 100% coverage.
After going down a rabbit hole of thinking that my pyproject.toml
settings weren't being picked up (eg the plugin not being activated, or similar), I discovered that the cause was that my pragma
rules were inverted.
I'd used:
if sys.version_info < (3, 11):
import tomli as tomllib # pragma: py-lt-311
else:
import tomllib # pragma: py-gte-311
Instead of:
if sys.version_info < (3, 11):
import tomli as tomllib # pragma: py-gte-311
else:
import tomllib # pragma: py-lt-311
I only discovered this by chance, after seeing:
#179 (comment)
I'd followed the docs, however they appear to have the example inverted too:
coverage-conditional-plugin/README.md
Lines 64 to 87 in 22c1093
In addition to fixing this example, maybe it's worth adding the `pragma: some` means `pragma: no cover if some`
explanation to the README too? (Given I'm not the first person to be confused about this, given #179 etc) :-)