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

Does this plugin works with module top-level pragmas. #2

Closed
proofit404 opened this issue Mar 17, 2020 · 2 comments · Fixed by #221
Closed

Does this plugin works with module top-level pragmas. #2

proofit404 opened this issue Mar 17, 2020 · 2 comments · Fixed by #221

Comments

@proofit404
Copy link

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 🎉

@Athanasius
Copy link

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.

@sobolevn
Copy link
Member

sobolevn commented Sep 30, 2022

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!

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

Successfully merging a pull request may close this issue.

3 participants