Serialize chained exceptions in xdist reports (pytest-dev__pytest-5787)#14
Open
emerson-gray wants to merge 1 commit intopytest-dev__pytest-5787from
Open
Serialize chained exceptions in xdist reports (pytest-dev__pytest-5787)#14emerson-gray wants to merge 1 commit intopytest-dev__pytest-5787from
emerson-gray wants to merge 1 commit intopytest-dev__pytest-5787from
Conversation
…add tests for round-trip and xdist output
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.
Problem\n- Under xdist, failures with chained exceptions only show the outermost exception. Non-xdist runs show the full chain with cause/context banners.\n\nRoot cause\n- Report serialization (_to_json/_from_json in src/_pytest/reports.py) only includes a single reprtraceback/reprcrash pair and drops ExceptionChainRepr.chain built by ExceptionInfo.getrepr(chain=True).\n\nChanges\n- Extend BaseReport._to_json to optionally include longrepr['chain'] with the complete list of (reprtraceback, reprcrash, descr) for each exception in the chain, while retaining top-level reprtraceback/reprcrash for compatibility.\n- Extend BaseReport._from_json to reconstruct an ExceptionChainRepr when 'chain' is present, fallback to ReprExceptionInfo otherwise.\n- Add tests: testing/test_reports_chain.py covers round-trip via _to_json/_from_json, hooks-based round-trip, and xdist (-n 1) output containing the cause banner.\n\nBackward compatibility\n- New serialized shape is additive; older consumers can continue to read outermost exception.\n\nVerification\n- Run: pytest testing/test_reports_chain.py (unit); run: pytest -q -n 1 testing/test_reports_chain.py::test_chained_exception_visible_with_xdist (integration, requires pytest-xdist).\n\nCloses #13