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

Function test_ini_controls_global_log_level

testing/logging/test_fixture.py:175–199  ·  view source on GitHub ↗
(pytester: Pytester)

Source from the content-addressed store, hash-verified

173
174
175def test_ini_controls_global_log_level(pytester: Pytester) -> None:
176 pytester.makepyfile(
177 """
178 import pytest
179 import logging
180 def test_log_level_override(request, caplog):
181 plugin = request.config.pluginmanager.getplugin('logging-plugin')
182 assert plugin.log_level == logging.ERROR
183 logger = logging.getLogger('catchlog')
184 logger.warning("WARNING message won't be shown")
185 logger.error("ERROR message will be shown")
186 assert 'WARNING' not in caplog.text
187 assert 'ERROR' in caplog.text
188 """
189 )
190 pytester.makeini(
191 """
192 [pytest]
193 log_level=ERROR
194 """
195 )
196
197 result = pytester.runpytest()
198 # make sure that that we get a '0' exit code for the testsuite
199 assert result.ret == 0
200
201
202def test_caplog_can_override_global_log_level(pytester: Pytester) -> None:

Callers

nothing calls this directly

Calls 3

makepyfileMethod · 0.45
makeiniMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected