-
-
Notifications
You must be signed in to change notification settings - Fork 464
Support .coveragerc.toml for configuration
#1952
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
Support .coveragerc.toml for configuration
#1952
Conversation
tests/test_config.py
Outdated
| @pytest.mark.parametrize("filename", ["pyproject.toml", ".coveragerc.toml"]) | ||
| def test_toml_config_file(self, filename) -> None: | ||
| # A pyproject.toml and coveragerc.toml will be read into the configuration. | ||
| self.make_file(filename, """\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the parameterization implemented appropriately, similar to pyproject.toml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
|
@nedbat, |
.coveragerc.toml for configuration.coveragerc.toml for configuration
nedbat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change needed.
tests/test_config.py
Outdated
| @pytest.mark.parametrize("filename", ["pyproject.toml", ".coveragerc.toml"]) | ||
| def test_toml_config_file(self, filename) -> None: | ||
| # A pyproject.toml and coveragerc.toml will be read into the configuration. | ||
| self.make_file(filename, """\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
tests/test_config.py
Outdated
| """) | ||
| with mock.patch.object(coverage.tomlconfig, "has_tomllib", False): | ||
| msg = "Can't read 'pyproject.toml' without TOML support" | ||
| msg = "Can't read '{filename}' without TOML support" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like tests are failing because this needs to be an f-string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. I will fix this error in the next commits. I run tox with version 3.12 locally, and I didn't see this error.
|
Thanks for doing this. There are some other changes needed. Let me know which you want to do, and which I should do:
|
Yes, I will add the changes |
4018790 to
673b0c0
Compare
673b0c0 to
c584e0d
Compare
webknjaz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz revert all the formatting changes. I marked some, find the rest.
6bee75f to
7565729
Compare
7565729 to
2558209
Compare
CHANGES.rst
Outdated
| .. _pull 1952: https://github.com/nedbat/coveragepy/pull/1952 | ||
|
|
||
|
|
||
| .. start-releases |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid conflict resolution?
doc/config.rst
Outdated
| [html] | ||
| directory = coverage_html_report | ||
| """, | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray edit?
tests/test_config.py
Outdated
| """\ | ||
| @pytest.mark.parametrize("filename", ["pyproject.toml", ".coveragerc.toml"]) | ||
| def test_toml_config_file(self, filename: str) -> None: | ||
| # A pyproject.toml and coveragerc.toml will be read into the configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # A pyproject.toml and coveragerc.toml will be read into the configuration. | |
| # A pyproject.toml and .coveragerc.toml will be read into the configuration. |
tests/test_config.py
Outdated
| def test_toml_parse_errors(self, bad_config: str, msg: str) -> None: | ||
| @pytest.mark.parametrize("filename", ["pyproject.toml", ".coveragerc.toml"]) | ||
| @pytest.mark.parametrize("bad_config, msg", [ | ||
| ("[tool.coverage.run]\ntimid = \"maybe?\"\n", r"maybe[?]"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A lot of reformatting?
tests/test_config.py
Outdated
| assert cov.config.xml_output == "/Users/me/somewhere/xml.out" | ||
| assert cov.config.exclude_list == ["~/data.file", "~joe/html_dir"] | ||
| assert cov.config.paths == {"mapping": ["/Users/me/src", "/Users/joe/source"]} | ||
| assert cov.config.paths == {'mapping': ['/Users/me/src', '/Users/joe/source']} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
tests/test_config.py
Outdated
| self.make_file( | ||
| "pyproject.toml", | ||
| """\ | ||
| self.make_file("pyproject.toml", """\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
05be667 to
0a508bf
Compare
|
I'm in progress - some tests have failed, I'm going to fix them |
@ofek yep. I will do the rebase, yesterday I had some issues with it for some reason. |
1f2edbb to
f746384
Compare
This adds .coveragerc.toml to the list of configuration files that coverage.py will automatically search for, with higher priority than pyproject.toml but lower than .coveragerc.
Converts existing pyproject.toml tests to be parametrized to also test .coveragerc.toml functionality, ensuring both TOML config formats work identically.
This test ensures that when both .coveragerc.toml and pyproject.toml are present, .coveragerc.toml takes precedence as intended.
…agerc.toml configuration file support
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
13a7188 to
9b6c00c
Compare
|
@nedbat please take a look at the PR to see if it's ready to be merged |
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
|
Thanks for persisting with this! <3 |
|
This landed in commit 21e726f |
|
This is now released as part of coverage 7.13.0. |
This patch provides a new configuration —
.coveragerc.toml. Considering that many projects have switched to toml configurations, this change offers a more flexible approach to manage coverage settings.Resolves #1643