Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7480b80

Browse files
committed
docs: make core messages accurate and documented
1 parent9a4a261 commit7480b80

File tree

10 files changed

+52
-68
lines changed

10 files changed

+52
-68
lines changed

‎CONTRIBUTORS.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ Mathieu Kniewallner
164164
Matt Bachmann
165165
Matthew Boehm
166166
Matthew Desmarais
167+
Matthias Schoettle
167168
Matus Valo
168169
Max Linke
169170
Mayank Singhal

‎coverage/core.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ def _debug(msg: str) -> None:
7272
# Check the conditions that preclude us from using sys.monitoring.
7373
reason_no_sysmon=""
7474
ifnotenv.PYBEHAVIOR.pep669:
75-
reason_no_sysmon="isn't available in this version"
75+
reason_no_sysmon="sys.monitoringisn't available in this version"
7676
elifconfig.branchandnotenv.PYBEHAVIOR.branch_right_left:
77-
reason_no_sysmon="can't measure branches in this version"
77+
reason_no_sysmon="sys.monitoringcan't measure branches in this version"
7878
elifdynamic_contexts:
79-
reason_no_sysmon="doesn't yet support dynamic contexts"
79+
reason_no_sysmon="itdoesn't yet support dynamic contexts"
8080
elifany((bad:=c)inconfig.concurrencyforcin ["greenlet","eventlet","gevent"]):
81-
reason_no_sysmon=f"doesn't support concurrency={bad}"
81+
reason_no_sysmon=f"itdoesn't support concurrency={bad}"
8282

8383
core_name:str|None=None
8484
ifconfig.timid:
@@ -92,7 +92,9 @@ def _debug(msg: str) -> None:
9292
ifcore_name=="sysmon"andreason_no_sysmon:
9393
_debug(f"core.py: raising ConfigError because sysmon not usable:{reason_no_sysmon}")
9494
raiseConfigError(
95-
f"Can't use core=sysmon: sys.monitoring{reason_no_sysmon}",skip_tests=True
95+
f"Can't use core=sysmon:{reason_no_sysmon}",
96+
skip_tests=True,
97+
slug="no-sysmon",
9698
)
9799

98100
ifcore_nameisNone:

‎doc/config.rst‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,21 @@ Before version 4.2, this option only accepted a single string.
333333
[run] core
334334
..........
335335

336-
(string) Specify which trace function implementation to use. Valid values are:
337-
"pytrace" for the pure Python implementation, "ctrace" for the C implementation
338-
(default until Python 3.13),
339-
or "sysmon" (Python 3.12+ only) for the
340-
:mod:`sys.monitoring <python:sys.monitoring>`
341-
implementation (default with Python 3.14+).
342-
343-
This was previously only available as the COVERAGE_CORE environment variable.
344-
Note that the "sysmon" core does not yet support plugins or dynamic contexts.
336+
(string, default depends on the Python version) Specify which measurement core
337+
to use. Valid values are:
338+
339+
- ``ctrace``: the C implementation of a sys.settrace function. This was the
340+
default until Python 3.13.
341+
342+
- ``sysmon``: the:mod:`sys.monitoring <python:sys.monitoring>` implementation.
343+
Only available in Python 3.12+, and the default in Python 3.14+. The sysmon
344+
core does not yet support plugins, dynamic contexts, or some concurrency
345+
libraries. In Python 3.12 and 3.13, it does not support branch coverage.
346+
347+
- ``pytrace``: the pure Python implementation of a sys.settrace function.
348+
349+
This setting was previously only available as the COVERAGE_CORE environment
350+
variable.
345351

346352
..versionadded::7.9
347353

‎doc/messages.rst‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ Can't combine (branch or statement) coverage data with (statement or branch) dat
5252
incompatible. You'll need to ensure that all of your data files are
5353
collected with the same settings.
5454

55+
.. _error_no_sysmon:
56+
57+
Can't use core=sysmon: sys.monitoring isn't available in this version
58+
You requested the sys.monitoring measurement core, but are running on
59+
Python 3.11 or lower where it isn't available.
60+
61+
Can't use core=sysmon: sys.monitoring can't measure branches in this version
62+
You requested the sys.monitoring measurement core and also branch coverage.
63+
This isn't supported until the Python 3.14.
64+
65+
Can't use core=sysmon: it doesn't yet support dynamic contexts
66+
You requested the sys.monitoring measurement core and also dynamic contexts.
67+
This isn't supported by coverage.py yet.
68+
69+
Can't use core=sysmon: it doesn't support concurrency=ZZZ
70+
5571

5672
.. _cmd_warnings:
5773
.. _warnings:
@@ -138,23 +154,6 @@ Couldn't import C tracer (no-ctracer)
138154
imported. The reason is included in the warning message. The Python tracer
139155
will be used instead.
140156

141-
.. _warning_no_sysmon:
142-
143-
sys.monitoring isn't available in this version, using default core (no-sysmon)
144-
You requested to use the sys.monitoring measurement core, but are running on
145-
Python 3.11 or lower where it isn't available. A default core will be used
146-
instead.
147-
148-
sys.monitoring can't measure branches in this version, using default core (no-sysmon)
149-
You requested the sys.monitoring measurement core and also branch coverage.
150-
This isn't supported until the later alphas of Python 3.14. A default core
151-
will be used instead.
152-
153-
sys.monitoring doesn't yet support dynamic contexts, using default core (no-sysmon)
154-
You requested the sys.monitoring measurement core and also dynamic contexts.
155-
This isn't supported by coverage.py yet. A default core will be used
156-
instead.
157-
158157

159158
Disabling warnings
160159
------------------

‎metacov.ini‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[run]
1010
branch = true
1111
data_file = ${COVERAGE_METAFILE-.metacov}
12-
disable_warnings = no-sysmon
1312
parallel = true
1413
relative_files = true
1514
source =

‎pyproject.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ filterwarnings = [
131131

132132
## Pytest warns if it can't collect things that seem to be tests. This should be an error.
133133
"error::pytest.PytestCollectionWarning",
134-
135-
"ignore:.*no-sysmon"
136134
]
137135

138136
# xfail tests that pass should fail the test suite

‎tests/conftest.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ def set_warnings() -> None:
5757
# https://github.com/python/cpython/issues/105539
5858
warnings.filterwarnings("ignore",r"unclosed database",category=ResourceWarning)
5959

60-
warnings.filterwarnings("ignore",r".*no-sysmon")
61-
6260
# We have a test that has a return in a finally: test_bug_1891.
6361
warnings.filterwarnings("ignore","'return' in a 'finally' block",category=SyntaxWarning)
6462

‎tests/test_concurrency.py‎

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,17 @@ def cant_trace_msg(concurrency: str, the_module: ModuleType | None) -> str | Non
183183
concurrency=",".join(parts)
184184

185185
iftestenv.SYS_MONandconcurrency:
186-
expected_out= (
187-
f"Can't use core=sysmon: sys.monitoring doesn't support concurrency={concurrency}\n"
188-
)
186+
expected_out=f"Can't use core=sysmon: it doesn't support concurrency={concurrency};"
189187
elifthe_moduleisNone:
190188
# We don't even have the underlying module installed, we expect
191189
# coverage to alert us to this fact.
192-
expected_out= (
193-
f"Couldn't trace with concurrency={concurrency}, the module isn't installed.\n"
194-
)
190+
expected_out=f"Couldn't trace with concurrency={concurrency}, the module isn't installed."
195191
eliftestenv.C_TRACERorconcurrency=="thread"orconcurrency=="":
196192
expected_out=None
197193
else:
198194
expected_out= (
199195
f"Can't support concurrency={concurrency} with{testenv.REQUESTED_TRACER_CLASS}, "
200-
+"only threads are supported.\n"
196+
+"only threads are supported."
201197
)
202198
returnexpected_out
203199

@@ -230,7 +226,7 @@ def try_some_code(
230226
expected_cant_trace=cant_trace_msg(concurrency,the_module)
231227

232228
ifexpected_cant_traceisnotNone:
233-
assertout==expected_cant_trace
229+
assertexpected_cant_traceinout
234230
pytest.skip(f"Can't test:{expected_cant_trace}")
235231
else:
236232
# We can fully measure the code if we are using the C tracer, which
@@ -406,7 +402,7 @@ def test_missing_module(self, module: str) -> None:
406402
self.make_file("prog.py","a = 1")
407403
sys.modules[module]=None# type: ignore[assignment]
408404
iftestenv.SYS_MON:
409-
msg=rf"Can't use core=sysmon:sys.monitoring doesn't support concurrency={module}"
405+
msg=rf"Can't use core=sysmon:it doesn't support concurrency={module}"
410406
else:
411407
msg=rf"Couldn't trace with concurrency={module}, the module isn't installed."
412408
withpytest.raises(ConfigError,match=msg):
@@ -501,8 +497,7 @@ def try_multiprocessing_code(
501497
expected_cant_trace=cant_trace_msg(concurrency,the_module)
502498

503499
ifexpected_cant_traceisnotNone:
504-
print(out)
505-
assertout==expected_cant_trace
500+
assertexpected_cant_traceinout
506501
pytest.skip(f"Can't test:{expected_cant_trace}")
507502
else:
508503
assertout.rstrip()==expected_out
@@ -579,9 +574,6 @@ def test_multiprocessing_with_branching(self, start_method: str) -> None:
579574
code= (SQUARE_OR_CUBE_WORK+MULTI_CODE).format(NPROCS=nprocs,UPTO=upto)
580575
total=sum(x*xifx%2elsex*x*xforxinrange(upto))
581576
expected_out=f"{nprocs} pids, total ={total}"
582-
expect_warn= (
583-
env.PYBEHAVIOR.pep669and (notenv.PYBEHAVIOR.branch_right_left)andtestenv.SYS_MON
584-
)
585577
self.make_file("multi.py",code)
586578
self.make_file(
587579
"multi.rc",
@@ -590,8 +582,7 @@ def test_multiprocessing_with_branching(self, start_method: str) -> None:
590582
concurrency = multiprocessing
591583
branch = True
592584
omit = */site-packages/*
593-
"""
594-
+ ("disable_warnings = no-sysmon"ifexpect_warnelse""),
585+
""",
595586
)
596587

597588
out=self.run_command(f"coverage run --rcfile=multi.rc multi.py{start_method}")

‎tests/test_core.py‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,9 @@ def test_core_request_sysmon(self) -> None:
8383
ifstatus==0:
8484
assertout.endswith("123 456\n")
8585
core=re_line(r" core:",out).strip()
86-
warns=re_lines(r"\(no-sysmon\)",out)
8786
assertcore=="core: SysMonitor"
88-
assertnotwarns
8987
else:
90-
assertout.endswith(
91-
"Can't use core=sysmon: sys.monitoring isn't available in this version\n"
92-
)
88+
assert"Can't use core=sysmon: sys.monitoring isn't available in this version;"inout
9389

9490
deftest_core_request_sysmon_no_dyncontext(self)->None:
9591
# Use config core= for this test just to be different.
@@ -103,12 +99,9 @@ def test_core_request_sysmon_no_dyncontext(self) -> None:
10399
)
104100
out=self.run_command("coverage run --debug=sys numbers.py",status=1)
105101
ifenv.PYBEHAVIOR.pep669:
106-
assert (
107-
"Can't use core=sysmon: sys.monitoring doesn't yet support dynamic contexts\n"
108-
inout
109-
)
102+
assert"Can't use core=sysmon: it doesn't yet support dynamic contexts;"inout
110103
else:
111-
assert"Can't use core=sysmon: sys.monitoring isn't available in this version\n"inout
104+
assert"Can't use core=sysmon: sys.monitoring isn't available in this version;"inout
112105

113106
deftest_core_request_sysmon_no_branches(self)->None:
114107
# Use config core= for this test just to be different.
@@ -124,19 +117,17 @@ def test_core_request_sysmon_no_branches(self) -> None:
124117
status=0
125118
elifenv.PYBEHAVIOR.pep669:
126119
status=1
127-
msg="Can't use core=sysmon: sys.monitoring can't measure branches in this version\n"
120+
msg="Can't use core=sysmon: sys.monitoring can't measure branches in this version;"
128121
else:
129122
status=1
130-
msg="Can't use core=sysmon: sys.monitoring isn't available in this version\n"
123+
msg="Can't use core=sysmon: sys.monitoring isn't available in this version;"
131124
out=self.run_command("coverage run --debug=sys numbers.py",status=status)
132125
ifstatus==0:
133126
assertout.endswith("123 456\n")
134127
core=re_line(r" core:",out).strip()
135-
warns=re_lines(r"\(no-sysmon\)",out)
136128
assertcore=="core: SysMonitor"
137-
assertnotwarns
138129
else:
139-
assertout.endswith(msg)# pylint: disable=possibly-used-before-assignment
130+
assertmsginout# pylint: disable=possibly-used-before-assignment
140131

141132
deftest_core_request_nosuchcore(self)->None:
142133
# Test the coverage misconfigurations in-process with pytest. Running a

‎tests/test_process.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1545,7 +1545,6 @@ def f2():
15451545
".coveragerc",
15461546
"""\
15471547
[run]
1548-
disable_warnings = no-sysmon
15491548
patch = subprocess
15501549
""",
15511550
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp