Skip to content

junitxml: build testcases per item instead of per phase - #15456

Draft
RonnyPfannschmidt wants to merge 4 commits into
mainfrom
claude/project-thread-i4efde
Draft

RonnyPfannschmidt wants to merge 4 commits into
mainfrom
claude/project-thread-i4efde

Conversation

@RonnyPfannschmidt

Copy link
Copy Markdown
Member

Requested by Ronny · project thread

🤖 Written by Claude Opus 5.5 via Claude Code for the pytest maintainers; I prompted it, it did the work, I read it.

junitxml decided what to write per phase report, so every edge case grew another flag (open_reports, cnt_double_fail_tests, and the ones proposed in #15196, #15357, #15236). This buffers each item's reports and builds its testcase element(s) at teardown. As a result file comes from the nodeid, line is 1-based, output is written once per element, tests= counts elements, subtests get their own testcases, and property names are escaped. Includes #15454's commit.

Closes #9388, closes #13876. Covers #15453 and the junitxml cases of #15196 and #15397.

Trade-offs

  • line switches from 0-based to 1-based (breaking for xunit1/legacy consumers that compensated).
  • Under xdist, elements are ordered by teardown arrival instead of first report (both are arbitrary).
  • xfail now gets captured output with junit_log_passing_tests=False.
  • A failed subtest also leaves the parent as a failure, so it shows as two failure elements.

Open decisions


Generated by Claude Code

surkuar and others added 2 commits November 25, 2026 14:54
The file attribute (xunit1/legacy families) came from Item.location,
which uses os.sep, so reports produced on Windows contained backslashes
while the nodeid uses '/'. Normalize to nodes.SEP in junitxml only, so
terminal output is unchanged.

Fixes #15453
Buffer the setup/call/teardown reports of each item and write its
testcase element(s) once the teardown report arrives, so output and
counts are decided with the whole item's outcome known.

- file comes from the nodeid (collected module, "/" separators),
  line is 1-based and omitted for tests defined in another module
- captured output is written once per testcase element
- tests= counts testcase elements; drops open_reports and
  cnt_double_fail_tests
- subtests become their own testcase elements
- property and attribute names are escaped like values

Closes #9388, closes #13876.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014GZsREjtdSBFcX2NKmt35c
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 25, 2026
@RonnyPfannschmidt RonnyPfannschmidt self-assigned this Nov 25, 2026
@cjyhjy

cjyhjy commented Nov 26, 2026

Copy link
Copy Markdown

Thanks, Ronny. If you decide to port tests from #15236, I’d suggest keeping two regressions: the fixture and unittest subtest comparison and the JUnit XML counts with two xdist workers. If you reuse those tests, I’d appreciate the Co-authored-by credit you mentioned.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

subtests not itemized in Junit XML junitxml: Incorrect (?) file reported for inherited tests

4 participants