$npx skillfedfor your agent

pytest-structlog

Structured logging assertions

Worth itPyPI TestingReleased Sep 2025286.5K downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_structlog-1.2-py3-none-any.whl
v1.2 · released 2025-09-10 · Python >=3.8 · 2 runtime deps: pytest, structlog

Yes. Low install friction, active maintenance, no known vulnerabilities, and MIT licensing make it a safe choice. If your test suite uses structlog for structured logging, this fixture is the standard way to assert on log output in pytest—it directly addresses a gap in testing structured logs that would otherwise require manual mocking or post-test log file inspection.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.8 or later; structlog must be configured in the code under test.
  • Low friction: pure Python wheel with only pytest and structlog as runtime dependencies.
  • Actively maintained with a recent release (338 days ago) and an active repository.

License · maintenance · safety

MIT (permissive) — MIT license permits use in proprietary and open-source projects with minimal restrictions; attribution required.

last release 2025-09-10 (338 days) · last repo commit 2026-08-01 · 67 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 286,541 downloads/mo, #8,041 on PyPI

Verify before relying

pip install pytest-structlog

# In your test file:
from pytest_structlog import StructuredLogCapture

def test_logging(log: StructuredLogCapture):
    # Your code that logs via structlog
    assert log.has("event message")
    assert len(log.events) == 1
  • Whether the fixture automatically captures all structlog output or requires explicit configuration in code under test.
  • Performance impact when capturing large numbers of log events in a single test.
Same gist for agents: .md · .json

What it is and what it does

pytest-structlog is a pytest plugin that integrates with structlog to capture and inspect structured log events during testing. It provides a `log` fixture that exposes captured events as a list and offers helper methods like `log.has()` for asserting that specific log messages with particular context were emitted. The fixture automatically configures structlog for testing purposes, stripping away production processors and replacing them with a test-friendly list-based collector.

The package lets you verify not just that logging occurred, but exactly what was logged—including event messages, log levels, and arbitrary context fields. You can assert on individual events, compare sequences of events, count occurrences, and use flexible matching patterns. It also provides command-line options and configuration file support to customize which structlog processors are kept or removed during testing, allowing you to preserve custom processors when needed.

Use it for

  • Verify that your application logs the correct messages and context when specific code paths execute.
  • Assert that errors or warnings are logged with the expected fields and severity levels during exception handling.
  • Test that batch operations log the right number of events and include required tracking or debugging information.
  • Validate that custom structlog processors are invoked correctly by inspecting the final event dictionaries.
  • Ensure sensitive information is not accidentally logged by checking event contents in security-focused tests.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

Low install friction, active maintenance, no known vulnerabilities, and MIT licensing make it a safe choice. If your test suite uses structlog for structured logging, this fixture is the standard way to assert on log output in pytest—it directly addresses a gap in testing structured logs that would otherwise require manual mocking or post-test log file inspection.

Install

pytest-structlog on PyPI

Before you install

Low friction: pure Python wheel with only pytest and structlog as runtime dependencies. Actively maintained with a recent release (338 days ago) and an active repository.

Requires Python 3.8 or later; structlog must be configured in the code under test.

License in practice

MIT license permits use in proprietary and open-source projects with minimal restrictions; attribution required.

Quickstart

pip install pytest-structlog

# In your test file:
from pytest_structlog import StructuredLogCapture

def test_logging(log: StructuredLogCapture):
    # Your code that logs via structlog
    assert log.has("event message")
    assert len(log.events) == 1

Verify before relying

  • Whether the fixture automatically captures all structlog output or requires explicit configuration in code under test.
  • Performance impact when capturing large numbers of log events in a single test.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.8
Install frictionLow. Pure-Python wheel
Runtime dependencies
2 packages
pyteststructlog
MaintenanceActively maintained 338 days since the last release
Last repo commit
First released
Downloads286,541 / month, #8,041 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Framework :: PytestProgramming Language :: PythonProgramming Language :: Python :: 3

Evidence: pytest_structlog-1.2-py3-none-any.whl

Tags

Capabilities
pytest structlog fixturestructured logging test assertionscapture structlog events in testspytest log verificationstructlog test helperassert on structured logspytest logging fixture
Topics
pytest-pluginstructured-loggingtest-assertions

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “pytest structlog fixture”

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also structlog-gcp · structlog-sentry · opentelemetry-instrumentation-structlog · structlog · django-structlog · macwinnie-enhanced-logging · structlog-pretty · pytest-harvest · pytest-loguru · pytest-assume