Hooks
provide.testkit.logger.hooks
¶
Pytest Hooks for Logger Management.
Provides pytest hooks for suppressing noisy loggers during test runs. This helps reduce test output noise from third-party libraries.
Functions¶
get_log_level_for_noisy_loggers
¶
Get the log level to set for noisy loggers.
Can be customized via the TESTKIT_NOISY_LOG_LEVEL environment variable. Defaults to WARNING level.
Returns:
| Type | Description |
|---|---|
int
|
Logging level (int) to set for noisy loggers. |
Source code in provide/testkit/logger/hooks.py
get_noisy_loggers
¶
Get the list of loggers to suppress during tests.
Can be customized via the TESTKIT_NOISY_LOGGERS environment variable, which should be a comma-separated list of logger names.
Returns:
| Type | Description |
|---|---|
list[str]
|
List of logger names to suppress. |
Source code in provide/testkit/logger/hooks.py
pytest_runtest_setup
¶
Hook that runs before each test setup.
This forcefully sets the log level for noisy libraries to WARNING (or custom level), overriding any configuration that may have happened at import time (e.g., by Textual or the application itself).
Source code in provide/testkit/logger/hooks.py
suppress_loggers
¶
Utility function to suppress specific loggers to a given level.
Can be used directly in tests or conftest.py files for custom suppression.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_names
|
list[str]
|
List of logger names to suppress |
required |
level
|
int
|
Log level to set (defaults to WARNING) |
WARNING
|