Does this plugin works with module top-level pragmas.
If I have a module in my library which should be imported only for Django 0.9.6, can I put # pragma: petrified_mammoth_shit right after coding comment?
Thanks for the awesome project :tada:
I'm just running into this same question. In our case we have config/darwin.py, config/linux.py and config/windows.py, each of which implements the interface of an ABC for a specific platform.
I need to be able to exclude all but the correct one from coverage reporting, depending on the platform being used.
I just tried this pyproject.toml:
[tool.coverage.run]
omit = [ "tests/*", "venv/*", "dist.win32/*" ]
plugins = [ "coverage_conditional_plugin" ]
[tool.coverage.coverage_conditional_plugin.rules]
sys-platform-win32 = "sys_platform == 'win32'"
sys-platform-not-win32 = "sys_platform != 'win32'"
sys-platform-darwin = "sys_platform == 'darwin'"
sys-platform-not-darwin = "sys_platform != 'darwin'"
sys-platform-linux = "sys_platform == 'linux'"
sys-platform-not-linux = "sys_platform != 'linux'"
And this in config/darwin.py, whilst running on Windows:
# pragma: sys-platform-not-darwin
...
But all that does is cause line 2 to be ignore, and everything from line 3 onwards to be reported as not covered.
Sorry, but this does not work. We can add this into our configuration:
[tool.coverage.coverage_conditional_plugin.modules]
"module.name" = "sys_platform != 'linux'"
PRs are welcome!