Skip to content

Comments

Serialize chained exceptions in xdist reports (pytest-dev__pytest-5787)#14

Open
emerson-gray wants to merge 1 commit intopytest-dev__pytest-5787from
fix-xdist-chained-exc-serialization
Open

Serialize chained exceptions in xdist reports (pytest-dev__pytest-5787)#14
emerson-gray wants to merge 1 commit intopytest-dev__pytest-5787from
fix-xdist-chained-exc-serialization

Conversation

@emerson-gray
Copy link

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

@emerson-gray emerson-gray requested a review from a team December 25, 2025 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant