Skip to content

Commit e37dd9d

Browse files
committed
docs: add new sys.monitoring warnings
1 parent 11e023e commit e37dd9d

File tree

4 files changed

+26
-7
lines changed

4 files changed

+26
-7
lines changed

coverage/control.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ def _init_for_start(self) -> None:
550550
warn=self._warn,
551551
config=self.config,
552552
dynamic_contexts=(should_start_context is not None),
553+
plugins=bool(self._plugins),
553554
metacov=self._metacov,
554555
)
555556
self._collector = Collector(
@@ -1399,9 +1400,6 @@ def process_startup() -> Coverage | None:
13991400
# started coverage.py in this process. Nothing to do.
14001401
return None
14011402

1402-
# # This runs at the start of pytest xdist workers, but also at other times?
1403-
# warnings.filterwarnings("ignore", r".*no-sysmon")
1404-
14051403
cov = Coverage(config_file=cps)
14061404
process_startup.coverage = cov # type: ignore[attr-defined]
14071405
cov._warn_no_data = False

coverage/core.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def __init__(
5858
warn: TWarnFn,
5959
config: CoverageConfig,
6060
dynamic_contexts: bool,
61+
plugins: bool,
6162
metacov: bool,
6263
) -> None:
6364
# Check the conditions that preclude us from using sys.monitoring.
@@ -68,6 +69,8 @@ def __init__(
6869
reason_no_sysmon = "can't measure branches in this version"
6970
elif dynamic_contexts:
7071
reason_no_sysmon = "doesn't yet support dynamic contexts"
72+
elif plugins:
73+
reason_no_sysmon = "doesn't yet support plugins"
7174

7275
core_name: str | None = None
7376
if config.timid:

doc/cmd.rst

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,31 @@ Conflicting dynamic contexts (dynamic-conflict)
273273
:meth:`.Coverage.switch_context` function to change the context. Only one of
274274
these mechanisms should be in use at a time.
275275

276-
sys.monitoring isn't available, using default core (no-sysmon)
276+
sys.monitoring isn't available in this version, using default core (no-sysmon)
277277
You requested to use the sys.monitoring measurement core, but are running on
278278
Python 3.11 or lower where it isn't available. A default core will be used
279279
instead.
280280

281+
sys.monitoring can't measure branches in this version, using default core (no-sysmon)
282+
You requested the sys.monitoring measurement core and also branch coverage.
283+
This isn't supported until the later alphas of Python 3.14. A default core
284+
will be used instead.
285+
286+
sys.monitoring doesn't yet support dynamic contexts, using default core (no-sysmon)
287+
You requested the sys.monitoring measurement core and also dynamic contexts.
288+
This isn't supported by coverage.py yet. A default core will be used
289+
instead.
290+
291+
sys.monitoring doesn't yet support plugins, using default core (no-sysmon)
292+
You requested the sys.monitoring measurement core and also are using some
293+
plugins. This isn't supported by coverage.py yet. A default core will be
294+
used instead.
295+
281296
Individual warnings can be disabled with the :ref:`disable_warnings
282-
<config_run_disable_warnings>` configuration setting. To silence "No data was
283-
collected," add this to your configuration file:
297+
<config_run_disable_warnings>` configuration setting. It is a list of the
298+
short parenthetical nicknames in the warning messages. For example, to silence
299+
"No data was collected (no-data-collected)", add this to your configuration
300+
file:
284301

285302
.. [[[cog
286303
show_configs(

tests/test_process.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,12 +1142,13 @@ def test_core_request_sysmon(self) -> None:
11421142
assert core in ("core: CTracer", "core: PyTracer")
11431143
assert warns
11441144

1145-
def test_core_request_nonsense(self) -> None:
1145+
def test_core_request_nosuchcore(self) -> None:
11461146
self.del_environ("COVERAGE_TEST_CORES")
11471147
self.set_environ("COVERAGE_CORE", "nosuchcore")
11481148
self.make_file("numbers.py", "print(123, 456)")
11491149
out = self.run_command("coverage run numbers.py")
11501150
assert "Unknown core value: 'nosuchcore'\n" in out
1151+
assert "123 456" not in out
11511152

11521153

11531154
class FailUnderNoFilesTest(CoverageTest):

0 commit comments

Comments
 (0)