MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_log_cli_enabled_disabled

Function test_log_cli_enabled_disabled

testing/logging/test_reporting.py:176–205  ·  view source on GitHub ↗
(pytester: Pytester, enabled: bool)

Source from the content-addressed store, hash-verified

174
175@pytest.mark.parametrize("enabled", [True, False])
176def test_log_cli_enabled_disabled(pytester: Pytester, enabled: bool) -> None:
177 msg = "critical message logged by test"
178 pytester.makepyfile(
179 """
180 import logging
181 def test_log_cli():
182 logging.critical("{}")
183 """.format(
184 msg
185 )
186 )
187 if enabled:
188 pytester.makeini(
189 """
190 [pytest]
191 log_cli=true
192 """
193 )
194 result = pytester.runpytest()
195 if enabled:
196 result.stdout.fnmatch_lines(
197 [
198 "test_log_cli_enabled_disabled.py::test_log_cli ",
199 "*-- live log call --*",
200 "CRITICAL *test_log_cli_enabled_disabled.py* critical message logged by test",
201 "PASSED*",
202 ]
203 )
204 else:
205 assert msg not in result.stdout.str()
206
207
208def test_log_cli_default_level(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 6

fnmatch_linesMethod · 0.80
strMethod · 0.80
makepyfileMethod · 0.45
formatMethod · 0.45
makeiniMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected