Registry / testing / pytest-logbook

pytest-logbook

JSON →
library1.2.0pypypi✓ verified 88d ago

pytest-logbook is a py.test plugin that captures Logbook log messages during test execution, making them available in test reports. The current version is 1.2.0, released with an irregular cadence.

pip install pytest-logbook
INSTALL
IMPORT
SIG · PYTEST-LOGBOOK
P
pytest-logbook
testingpythonv1.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pytest_logbook
✓ import pytest_logbook
Used to configure logging level via pytest.mark.logbook or set log_level fixture.

Basic usage: use the log_level fixture to set the logging level for a test.

# test_my_module.py import logging def test_with_logging(log_level): log_level('DEBUG') logger = logging.getLogger(__name__) logger.debug('Debug message') assert True
Debug
Known issues
gotchaThe plugin only captures output from the 'logbook' library, not the standard 'logging' module. If your code uses stdlib logging, this plugin won't capture messages.
fix
Use pytest-catchlog or the built-in caplog fixture for stdlib logging.
affects: all
gotchaThe log_level fixture must be requested as a test parameter; it doesn't work as a session-scoped fixture.
fix
Pass 'log_level' as a parameter to each test function that needs it.
affects: all
deprecatedThe '--log-level' command-line option was deprecated in version 1.2.0 in favor of using the log_level fixture.
fix
Use the log_level fixture instead of the CLI option.
affects: >=1.2.0
Errors
Common errors & fixes
Logbook library not installed
The plugin requires logbook to be installed.
fix
pip install logbook
No module named 'pytest_logbook'
The plugin is not installed or imported directly.
fix
pip install pytest-logbook and rely on pytest's plugin discovery; do not import manually.
AttributeError: 'NoneType' object has no attribute 'info'
The log_level fixture not properly set or logger not correctly configured.
fix
Ensure the log_level fixture is used and the logger is from logbook, not stdlib.
Upgrade
Version history
1.2.0latest on PyPI · released Nov 23, 2015
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
pytest-logbook — pip install pytest-logbook · libregistry