Report failures before the pytest hard-exit#24
Open
aleksUIX wants to merge 1 commit into
Open
Conversation
The os._exit workaround for the chromadb/posthog atexit shutdown hang (ar-r82f.21) lived in pytest_sessionfinish, which runs before the terminal reporter prints the FAILURES section, short summary, and stats line. Every failing run ended with a bare F and no diagnostics, locally and in CI logs. Two changes preserve the workaround while restoring reporting: - record the exit status in pytest_sessionfinish and hard-exit from pytest_unconfigure instead, which fires after all reporting - flush stdout/stderr before os._exit, since it skips stdio flushing and block-buffered output (file redirects, CI logs) otherwise loses the report even when the hook order is right Exit status propagation is unchanged. Full unit suite completes in about 6 seconds with no shutdown hang.
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
Any failing test run currently produces a bare
Fand exit code 1 with zero diagnostics, locally and in CI logs. Theos._exitshutdown workaround intests/conftest.pyfires before pytest prints the FAILURES section, and it also drops buffered output. This PR keeps the workaround (the chromadb/posthog atexit hang it dodges is real) while restoring failure reporting.Before / after
Before, on a clean checkout (
pytest tests/unit/test_openrtb_parser.py -q):That is the entire output. After:
Why two changes
pytest_sessionfinishhooks run, so hard-exiting there kills reporting. The exit now happens inpytest_unconfigure, which fires after all reporting;pytest_sessionfinishonly records the exit status.os._exit:os._exitskips stdio flushing, so with block-buffered output (file redirect, CI log capture) the report was lost even with correct hook order. Both streams are flushed first.Verification
ruff checkclean.The failing test shown above is a separate fresh-clone issue; a follow-up PR ports the skip pattern buyer merged in buyer-agent#92.