pytest-loguru
Pytest Loguru
What it is and what it does
pytest-loguru is a pytest plugin that bridges loguru's structured logging with pytest's built-in caplog fixture. When you use loguru for logging in your application, pytest's standard caplog fixture does not capture those logs by default—this plugin solves that by making loguru logs available through caplog, so you can write assertions on them just as you would with the standard library's logging module.
The plugin is lightweight, requiring only loguru as a runtime dependency, and works across Python 3.8 through 3.12 on all major operating systems. It's maintained actively and carries no known security vulnerabilities, making it a straightforward addition to test suites that already use loguru for application logging.
Use it for:
- Verify that your application logs specific messages at the correct log level during unit tests
- Assert that error or warning logs are emitted when expected in exception-handling code paths
- Capture and inspect structured log fields added by loguru in test assertions
- Ensure log output does not contain sensitive information before it reaches production
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extends pytest's caplog fixture to capture and assert on logs produced by loguru, enabling structured logging verification in pytest tests.
Yes. If you use loguru in your application and pytest for testing, this plugin is a straightforward, low-friction addition that removes a gap in test observability. It has no known vulnerabilities, active maintenance, and a permissive license. Install it if you need to assert on loguru output in tests.
Install
pytest-loguru on PyPI
pip
pip install pytest-loguruuv
uv add pytest-logurupoetry
poetry add pytest-loguruInstalling pytest-loguru
Before you install
Low friction: pure Python wheel with a single runtime dependency on loguru. Active maintenance with a recent release (90 days ago) and no known vulnerabilities.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and proprietary projects.
Quickstart
pip install pytest-loguru
import pytest
from loguru import logger
def test_logging(caplog):
logger.info("test message")
assert "test message" in caplog.text
Verify before relying
- Whether caplog integration works with all loguru sink types or only standard handlers
- Performance impact when capturing high-volume loguru output in large test suites
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — loguru |
| Maintenance | actively maintained — 90 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 302,970/month — #7,817 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_loguru-0.4.1-py3-none-any.whl
Keywords: loguru, py.test, pytest
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
pytest-catchlogA pytest plugin that automatically captures log…
permissive · top 15,000 on PyPI
loguruLoguru provides a pre-configured logger that…
permissive · top 1,000 on PyPI
tdd-guard-pytestA pytest plugin that captures test results and…
permissive · top 15,000 on PyPI
pytest-fakerProvides pytest fixtures that integrate the…
permissive · top 15,000 on PyPI
pytest-base-urlA pytest plugin that injects a configurable…
copyleft · top 5,000 on PyPI
pytest-qtpytest-qt is a pytest plugin that provides…
permissive · top 5,000 on PyPI
pytest-printAdds fixtures to pytest that print messages…
permissive · top 15,000 on PyPI
pytest-runtime-xfailA pytest plugin that provides a `runtime_xfail`…
permissive · top 15,000 on PyPI
pytest-subtestsAdds subTest() support to pytest, allowing…
permissive · top 5,000 on PyPI
pytest-raisesProvides pytest markers (@pytest.mark.raises…
unclear · top 15,000 on PyPI