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
)
| 219 | ], |
| 220 | ) |
| 221 | def 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 | |
| 242 | def test_log_access(caplog: pytest.LogCaptureFixture) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…