Ensure that 'set_level' is undone after the end of the test (handler). Issue #7569. Tests the handler level specifically.
(pytester: Pytester)
| 55 | |
| 56 | |
| 57 | def 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 | |
| 85 | def test_with_statement(caplog): |
nothing calls this directly
no test coverage detected