From cc0c0ea4b2af02e8bf4c21f708afa6988e1b4fda Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 22 Feb 2023 17:13:40 -0500 Subject: [PATCH] docs: final paperwork for exclude_also #1557 --- CHANGES.rst | 7 +++++++ CONTRIBUTORS.txt | 1 + doc/config.rst | 9 ++++++--- tests/test_config.py | 5 +++-- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 1c27501da..d2db59c98 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,6 +20,10 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- +- Added a new setting ``[report] exclude_also`` to let you add more exclusions + without overwriting the defaults. Thanks, `Alpha Chen `_, + closing `issue 1391_`. + - Added a :meth:`.CoverageData.purge_files` method to remove recorded data for a particular file. Contributed by `Stephan Deibel `_. @@ -39,11 +43,14 @@ Unreleased - Added a ``py.typed`` file to announce our type-hintedness. Thanks, `KotlinIsland `_. +.. _issue 1391: https://github.com/nedbat/coveragepy/issues/1391 .. _issue 1542: https://github.com/nedbat/coveragepy/issues/1542 .. _pull 1543: https://github.com/nedbat/coveragepy/pull/1543 .. _pull 1547: https://github.com/nedbat/coveragepy/pull/1547 .. _pull 1550: https://github.com/nedbat/coveragepy/pull/1550 .. _issue 1552: https://github.com/nedbat/coveragepy/issues/1552 +.. _pull 1557: https://github.com/nedbat/coveragepy/pull/1557 + .. scriv-start-here diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 8889ed612..f9f028a4d 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -14,6 +14,7 @@ Alex Groce Alex Sandro Alexander Todorov Alexander Walters +Alpha Chen Ammar Askar Andrew Hoos Anthony Sottile diff --git a/doc/config.rst b/doc/config.rst index 5b159d900..152b3af48 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -400,9 +400,12 @@ you'll exclude any line with three or more of any character. If you write [report] exclude_also ..................... -(multi-string) A list of regular expressions. This setting will preserve the -default exclude pattern instead of overwriting it. See -:ref:`config_report_exclude_lines` for details on exclusion regexes. +(multi-string) A list of regular expressions. This setting is the same as +:ref:`config_report_exclude_lines`: it adds patterns for lines to exclude from +reporting. This setting will preserve the default exclude patterns instead of +overwriting them. + +.. versionadded:: 7.2.0 .. _config_report_fail_under: diff --git a/tests/test_config.py b/tests/test_config.py index 2befa2e3b..6739a426f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -452,11 +452,12 @@ def test_exceptions_from_missing_things(self) -> None: def test_exclude_also(self) -> None: self.make_file("pyproject.toml", """\ [tool.coverage.report] - exclude_also = ["foobar"] + exclude_also = ["foobar", "raise .*Error"] """) cov = coverage.Coverage() - assert cov.config.exclude_list == coverage.config.DEFAULT_EXCLUDE + ["foobar"] + expected = coverage.config.DEFAULT_EXCLUDE + ["foobar", "raise .*Error"] + assert cov.config.exclude_list == expected class ConfigFileTest(UsingModulesMixin, CoverageTest):