MCPcopy Index your code
hub / github.com/pytest-dev/pytest / test_force_enable_logging_level_string

Function test_force_enable_logging_level_string

testing/logging/test_fixture.py:221–239  ·  view source on GitHub ↗

Test _force_enable_logging using a level string. ``expected_disable_level`` is one level below ``level_str`` because the disabled log level always needs to be *at least* one level lower than the level that caplog is trying to capture.

(
    caplog: pytest.LogCaptureFixture, level_str: str, expected_disable_level: int
)

Source from the content-addressed store, hash-verified

219 ],
220)
221def test_force_enable_logging_level_string(
222 caplog: pytest.LogCaptureFixture, level_str: str, expected_disable_level: int
223) -> None:
224 """Test _force_enable_logging using a level string.
225
226 ``expected_disable_level`` is one level below ``level_str`` because the disabled log level
227 always needs to be *at least* one level lower than the level that caplog is trying to capture.
228 """
229 test_logger = logging.getLogger("test_str_level_force_enable")
230 # Emulate a testing environment where all logging is disabled.
231 logging.disable(logging.CRITICAL)
232 # Make sure all logging is disabled.
233 assert not test_logger.isEnabledFor(logging.CRITICAL)
234 # Un-disable logging for `level_str`.
235 caplog._force_enable_logging(level_str, test_logger)
236 # Make sure that the disabled level is now one below the requested logging level.
237 # We don't use `isEnabledFor` here because that also checks the level set by
238 # `logging.setLevel()` which is irrelevant to `logging.disable()`.
239 assert test_logger.manager.disable == expected_disable_level
240
241
242def test_log_access(caplog: pytest.LogCaptureFixture) -> None:

Callers

nothing calls this directly

Calls 1

_force_enable_loggingMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…