skillfed

pytest-loguru

Pytest Loguru

pytest-loguru v0.4.1 303.0K downloads/30d#7,817 on PyPI33
Permissive license MIT Active released

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-loguru

uv

uv add pytest-loguru

poetry

poetry add pytest-loguru

Installing 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

Development Status :: 5 - Production/StableFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseNatural Language :: EnglishOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: POSIX :: LinuxOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTyping :: Typed

Tags

pytest loguru integrationcaplog fixture loguruloguru log capture pyteststructured logging pytestloguru test assertions
pytest-pluginloggingtest-fixtures

More Python Modules packages