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

Add support for omitting entire modules #221

Merged
merged 5 commits into from Jun 2, 2023
Merged

Add support for omitting entire modules #221

merged 5 commits into from Jun 2, 2023

Conversation

br3ndonland
Copy link
Contributor

Description

This PR will enable entire modules to be conditionally omitted from test coverage measurement (#2).

Changes

Modules will be omitted using the coverage.py [run] omit configuration setting.

The syntax for omitting modules will be slightly different from the suggestion by @sobolevn (#2 (comment)) to align more closely with the file pattern syntax used by coverage.py.

[tool.coverage.run]
plugins = ["coverage_conditional_plugin"]

[tool.coverage.coverage_conditional_plugin.omit]
"my_project/omit*.py" = "sys_platform == 'win32'"

Related

This commit will enable entire modules to be conditionally omitted from
test coverage measurement. Modules will be omitted using the coverage.py
`[run] omit` configuration setting.

https://coverage.readthedocs.io/en/stable/config.html#run-omit
https://coverage.readthedocs.io/en/stable/source.html
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This seems very useful!

I have just one nit to apply :)

coverage_conditional_plugin/__init__.py Outdated Show resolved Hide resolved
@br3ndonland
Copy link
Contributor Author

Thanks for the prompt review @sobolevn!

I'm happy to consider the nit you suggested, but it makes type annotations more complicated, and the for omit in omits.items(): syntax won't work for the filter returned from the INI file format.

It looks like we need to update gitpython to resolve the vulnerability reported by poetry run safety check --full-report. I've pushed that update.

@Kludex
Copy link

Kludex commented Jun 1, 2023

What's missing here?

@sobolevn sobolevn closed this Jun 1, 2023
@sobolevn sobolevn reopened this Jun 1, 2023
@sobolevn
Copy link
Member

sobolevn commented Jun 1, 2023

I can work on it and finish it tomorrow.

@Kludex
Copy link

Kludex commented Jun 1, 2023

I can work on it and finish it tomorrow.

I didn't mean to give you work, I really wanted to know what was missing hahaha

...but thanks.

@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Merging #221 (c8debc2) into master (1c715a8) will decrease coverage by 11.97%.
The diff coverage is 62.50%.

@@             Coverage Diff             @@
##           master     #221       +/-   ##
===========================================
- Coverage   90.90%   78.94%   -11.97%     
===========================================
  Files           1        4        +3     
  Lines          11       19        +8     
===========================================
+ Hits           10       15        +5     
- Misses          1        4        +3     
Impacted Files Coverage Δ
test_project/compat.py 50.00% <50.00%> (ø)
test_project/omit1.py 50.00% <50.00%> (ø)
test_project/omit2.py 50.00% <50.00%> (ø)
test_project/example.py 92.30% <100.00%> (+1.39%) ⬆️

@sobolevn
Copy link
Member

sobolevn commented Jun 2, 2023

Thank you! Great idea!

@sobolevn sobolevn merged commit 2c70523 into wemake-services:master Jun 2, 2023
5 of 7 checks passed
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 this pull request may close these issues.

Does this plugin works with module top-level pragmas.
3 participants