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

Function test_log_cli_ini_level

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

Source from the content-addressed store, hash-verified

547
548
549def test_log_cli_ini_level(pytester: Pytester) -> None:
550 pytester.makeini(
551 """
552 [pytest]
553 log_cli=true
554 log_cli_level = INFO
555 """
556 )
557 pytester.makepyfile(
558 """
559 import pytest
560 import logging
561 def test_log_cli(request):
562 plugin = request.config.pluginmanager.getplugin('logging-plugin')
563 assert plugin.log_cli_handler.level == logging.INFO
564 logging.getLogger('catchlog').debug("This log message won't be shown")
565 logging.getLogger('catchlog').info("This log message will be shown")
566 print('PASSED')
567 """
568 )
569
570 result = pytester.runpytest("-s")
571
572 # fnmatch_lines does an assertion internally
573 result.stdout.fnmatch_lines(
574 [
575 "*test_log_cli_ini_level.py* This log message will be shown",
576 "PASSED", # 'PASSED' on its own line because the log message prints a new line
577 ]
578 )
579 result.stdout.no_fnmatch_line("*This log message won't be shown*")
580
581 # make sure that we get a '0' exit code for the testsuite
582 assert result.ret == 0
583
584
585@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected