{"categories":[{"label":"Testing","url":"https://skillfed.io/packages/category/software-development-testing/4"}],"enrichment":{"capability":"Provides a pytest fixture for capturing and asserting on structured logs produced by structlog, enabling test-friendly inspection of log events and their context.","skillfed_tags":["pytest-plugin","structured-logging","test-assertions"],"use_cases":["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."],"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.\n\nThe package lets you verify not just that logging occurred, but exactly what was logged\u2014including 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.","worth_installing":"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\u2014it directly addresses a gap in testing structured logs that would otherwise require manual mocking or post-test log file inspection."},"id":"pytest-structlog","links":{"html":"https://skillfed.io/packages/pytest-structlog","md":"https://skillfed.io/packages/pytest-structlog.md","pypi":"https://pypi.org/project/pytest-structlog/"},"maintenance":{"status":"active"},"meta":{"latest_release":"2025-09-10","license_spdx":"MIT","license_treatment":"permissive","name":"pytest-structlog","python_support":"supports_current","summary":"Structured logging assertions"},"popularity":{"monthly_downloads":286541,"position":8041,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"1.2"}
