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

Function test_log_cli_default_level

testing/logging/test_reporting.py:208–239  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

206
207
208def test_log_cli_default_level(pytester: Pytester) -> None:
209 # Default log file level
210 pytester.makepyfile(
211 """
212 import pytest
213 import logging
214 def test_log_cli(request):
215 plugin = request.config.pluginmanager.getplugin('logging-plugin')
216 assert plugin.log_cli_handler.level == logging.NOTSET
217 logging.getLogger('catchlog').info("INFO message won't be shown")
218 logging.getLogger('catchlog').warning("WARNING message will be shown")
219 """
220 )
221 pytester.makeini(
222 """
223 [pytest]
224 log_cli=true
225 """
226 )
227
228 result = pytester.runpytest()
229
230 # fnmatch_lines does an assertion internally
231 result.stdout.fnmatch_lines(
232 [
233 "test_log_cli_default_level.py::test_log_cli ",
234 "WARNING*test_log_cli_default_level.py* message will be shown*",
235 ]
236 )
237 result.stdout.no_fnmatch_line("*INFO message won't be shown*")
238 # make sure that we get a '0' exit code for the testsuite
239 assert result.ret == 0
240
241
242def test_log_cli_default_level_multiple_tests(

Callers

nothing calls this directly

Calls 5

fnmatch_linesMethod · 0.80
no_fnmatch_lineMethod · 0.80
makepyfileMethod · 0.45
makeiniMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected