fix(ingestion): capture structlog output in pytest caplog - #1029
Open
parker-cassar wants to merge 8 commits into
Open
fix(ingestion): capture structlog output in pytest caplog#1029parker-cassar wants to merge 8 commits into
parker-cassar wants to merge 8 commits into
Conversation
Recording issue choice and local setup notes for Module 3.
Documented the failing caplog repro and the intended conftest fix.
Configure structlog with a stdlib LoggerFactory in the test suite so warning events reach pytest's caplog fixture. Fixes empty-chunks assertions without changing production logging. Fixes ascherj#159
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wire structlog into stdlib logging for the test suite so pytest's
caplogfixture can see application log events. This fixes suite-wide failures where structlog printed warnings to stdout butcaplog.textstayed empty (notablytest_empty_chunks_list_returns_empty).Issue
Closes #159
Changes
configure_structlog_for_caplogfixture intests/conftest.pythat configures structlog withLoggerFactory, stdlib processors, andConsoleRenderer, then resets defaults after each testtests/unit/test_structlog_caplog.pycovering warning and info capture viacaplogTesting
test_empty_chunks_list_returns_emptyand new structlog/caplog tests)make test-integration) — not required for this test-only changeruff check tests/conftest.py tests/unit/test_structlog_caplog.py)Pre-existing failures (unchanged by this PR)
make checkand fullmake test-unitalready fail onmainfor unrelated reasons. Before this change: 55 failed, 375 passed. After: 52 failed, 378 passed (the empty-chunks caplog failure plus the two new tests now pass; remaining failures are pre-existing in bias_detector, faithfulness_checker, pii_scrubber, review_service, etc.). Lint reports ~182 ruff errors and mypy reports ~103 errors across the codebase, none in the files this PR touches.Screenshots / Demo
N/A (test infrastructure only)
Notes for Reviewers
core/logging.pyis intentionally unchangedcache_logger_on_first_use=Falseso module-levelstructlog.get_logger()proxies pick up the test configconfigure_logging()directly