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

Function test_change_level_undos_handler_level

testing/logging/test_fixture.py:57–82  ·  view source on GitHub ↗

Ensure that 'set_level' is undone after the end of the test (handler). Issue #7569. Tests the handler level specifically.

(pytester: Pytester)

Source from the content-addressed store, hash-verified

55
56
57def test_change_level_undos_handler_level(pytester: Pytester) -> None:
58 """Ensure that 'set_level' is undone after the end of the test (handler).
59
60 Issue #7569. Tests the handler level specifically.
61 """
62 pytester.makepyfile(
63 """
64 import logging
65
66 def test1(caplog):
67 assert caplog.handler.level == 0
68 caplog.set_level(9999)
69 caplog.set_level(41)
70 assert caplog.handler.level == 41
71
72 def test2(caplog):
73 assert caplog.handler.level == 0
74
75 def test3(caplog):
76 assert caplog.handler.level == 0
77 caplog.set_level(43)
78 assert caplog.handler.level == 43
79 """
80 )
81 result = pytester.runpytest()
82 result.assert_outcomes(passed=3)
83
84
85def test_with_statement(caplog):

Callers

nothing calls this directly

Calls 3

assert_outcomesMethod · 0.80
makepyfileMethod · 0.45
runpytestMethod · 0.45

Tested by

no test coverage detected