Skip to content

Commit 6f32948

Browse files
committed
fix: unknown patches should be errors, not warnings
1 parent d33af7e commit 6f32948

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

coverage/patch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from typing import NoReturn, TYPE_CHECKING
1111

12+
from coverage.exceptions import ConfigError
13+
1214
if TYPE_CHECKING:
1315
from coverage import Coverage
1416
from coverage.config import CoverageConfig
@@ -28,4 +30,4 @@ def _coverage_os_exit_patch(status: int) -> NoReturn:
2830
_old_os_exit(status)
2931
os._exit = _coverage_os_exit_patch
3032
else:
31-
cov._warn(f"Unknown patch {patch!r}, ignored", slug="unknown-patch")
33+
raise ConfigError(f"Unknown patch {patch!r}")

doc/cmd.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ sys.monitoring doesn't yet support dynamic contexts, using default core (no-sysm
300300
This isn't supported by coverage.py yet. A default core will be used
301301
instead.
302302

303-
Unknown patch 'XYZ', ignored (unknown-patch)
304-
You specified an incorrect patch name in the :ref:`config_run_patch` setting.
305-
306303
Individual warnings can be disabled with the :ref:`disable_warnings
307304
<config_run_disable_warnings>` configuration setting. It is a list of the
308305
short parenthetical nicknames in the warning messages. For example, to silence

tests/test_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from coverage.types import FilePathClasses, FilePathType
2020

2121
from tests.coveragetest import CoverageTest, UsingModulesMixin
22-
from tests.helpers import assert_coverage_warnings
22+
2323

2424
class ConfigTest(CoverageTest):
2525
"""Tests of the different sources of configuration settings."""
@@ -477,10 +477,10 @@ def test_unknown_patch(self) -> None:
477477
os._exit
478478
xyzzy
479479
""")
480-
with pytest.warns(CoverageWarning) as warns:
480+
msg = "Unknown patch 'xyzzy'"
481+
with pytest.raises(ConfigError, match=msg):
481482
cov = coverage.Coverage()
482483
self.start_import_stop(cov, "foo")
483-
assert_coverage_warnings(warns, "Unknown patch 'xyzzy', ignored (unknown-patch)")
484484

485485
def test_misplaced_option(self) -> None:
486486
self.make_file(".coveragerc", """\

0 commit comments

Comments
 (0)