-
-
Notifications
You must be signed in to change notification settings - Fork 447
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
base: master
Are you sure you want to change the base?
Support .coveragerc.toml
for configuration
#1952
Conversation
This patch provides a new configuration option for coverage.py. Considering that many projects have switched to toml configurations, this change offers a more flexible approach to manage coverage settings.
(".coveragerc.toml", True, False), | ||
("setup.cfg", False, False), |
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 priority of the new config properly determined in the config_files_to_try
function?
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 good.
@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.
def test_coveragerc_toml_priority(self) -> None: | ||
"""Test that .coveragerc.toml has priority over 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.
Is testing priority only over pyproject.tom
l in the test_coveragerc_toml_priority
test sufficient?
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
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.
(".coveragerc.toml", True, False), | ||
("setup.cfg", False, False), |
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 good.
@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.
def test_coveragerc_toml_priority(self) -> None: | ||
"""Test that .coveragerc.toml has priority over 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.
tests/test_config.py
Outdated
# A toml file! | ||
[tool.coverage] | ||
run.parallel = true | ||
""") | ||
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 |
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
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