coverage-conditional-plugin icon indicating copy to clipboard operation
coverage-conditional-plugin copied to clipboard

Readme rule examples are inverted

Open edmorley opened this issue 3 years ago • 0 comments

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: https://github.com/wemake-services/coverage-conditional-plugin/issues/179#issuecomment-1257983849

I'd followed the docs, however they appear to have the example inverted too: https://github.com/wemake-services/coverage-conditional-plugin/blob/22c109369cee92c7d3b49cf7d3a743c4830263f8/README.md?plain=1#L64-L87

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) :-)

edmorley avatar Dec 22 '22 11:12 edmorley