-
-
Notifications
You must be signed in to change notification settings - Fork 456
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?
Changes from all commits
21b5748
d8be467
40608ea
74fcd88
020cf77
7619dfd
b66b7bf
2558209
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -644,6 +644,7 @@ def config_files_to_try(config_file: bool | str) -> list[tuple[str, bool, bool]] | |
assert isinstance(config_file, str) | ||
files_to_try = [ | ||
(config_file, True, specified_file), | ||
(".coveragerc.toml", True, False), | ||
("setup.cfg", False, False), | ||
Comment on lines
+647
to
648
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the priority of the new config properly determined in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good. |
||
("tox.ini", False, False), | ||
("pyproject.toml", False, False), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,12 +39,15 @@ environment variable. | |
|
||
If ``.coveragerc`` doesn't exist and another file hasn't been specified, then | ||
coverage.py will look for settings in other common configuration files, in this | ||
order: setup.cfg, tox.ini, or pyproject.toml. The first file found with | ||
order: .coveragerc.toml, setup.cfg, tox.ini, or pyproject.toml. The first file | ||
found with | ||
coverage.py settings will be used and other files won't be consulted. | ||
|
||
Coverage.py will read from "pyproject.toml" if TOML support is available, | ||
Coverage.py will read from ".coveragerc.toml" and "pyproject.toml" if TOML | ||
support is available, | ||
either because you are running on Python 3.11 or later, or because you | ||
installed with the ``toml`` extra (``pip install coverage[toml]``). | ||
installed with the ``toml`` extra (``pip install coverage[toml]``). Both files | ||
use the same ``[tool.coverage]`` section structure. | ||
|
||
|
||
Syntax | ||
|
@@ -136,6 +139,7 @@ Here's a sample configuration file, in each syntax: | |
[html] | ||
directory = coverage_html_report | ||
""", | ||
|
||
OlenaYefymenko marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stray edit? |
||
toml=r""" | ||
[tool.coverage.run] | ||
branch = true | ||
|
@@ -198,6 +202,36 @@ Here's a sample configuration file, in each syntax: | |
[html] | ||
directory = coverage_html_report | ||
|
||
.. code-tab:: toml | ||
:caption: .coveragerc.toml | ||
|
||
[tool.coverage.run] | ||
branch = true | ||
|
||
[tool.coverage.report] | ||
# Regexes for lines to exclude from consideration | ||
exclude_also = [ | ||
# Don't complain about missing debug-only code: | ||
"def __repr__", | ||
"if self\\.debug", | ||
|
||
# Don't complain if tests don't hit defensive assertion code: | ||
"raise AssertionError", | ||
"raise NotImplementedError", | ||
|
||
# Don't complain if non-runnable code isn't run: | ||
"if 0:", | ||
"if __name__ == .__main__.:", | ||
|
||
# Don't complain about abstract methods, they aren't run: | ||
"@(abc\\.)?abstractmethod", | ||
] | ||
|
||
ignore_errors = true | ||
|
||
[tool.coverage.html] | ||
directory = "coverage_html_report" | ||
|
||
.. code-tab:: toml | ||
:caption: pyproject.toml | ||
|
||
|
@@ -257,7 +291,7 @@ Here's a sample configuration file, in each syntax: | |
[coverage:html] | ||
directory = coverage_html_report | ||
|
||
.. [[[end]]] (sum: HU1Z62mvRK) | ||
.. [[[end]]] (sum: EQ1Fn4BHJk) | ||
|
||
|
||
The specific configuration settings are described below. Many sections and | ||
|
@@ -597,6 +631,16 @@ equivalent when combining data from different machines: | |
/jenkins/build/*/src | ||
c:\myproj\src | ||
|
||
.. code-tab:: toml | ||
:caption: .coveragerc.toml | ||
|
||
[tool.coverage.paths] | ||
source = [ | ||
"src/", | ||
"/jenkins/build/*/src", | ||
"c:\\myproj\\src", | ||
] | ||
|
||
.. code-tab:: toml | ||
:caption: pyproject.toml | ||
|
||
|
@@ -616,7 +660,7 @@ equivalent when combining data from different machines: | |
/jenkins/build/*/src | ||
c:\myproj\src | ||
|
||
.. [[[end]]] (sum: oHSl8SGiMT) | ||
.. [[[end]]] (sum: QLgJoxGH3G) | ||
|
||
|
||
The names of the entries ("source" in this example) are ignored, you may choose | ||
|
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?