Skip to content

Fix missing JUnit XML output for setup errors - #15196

Draft
cty-ut wants to merge 2 commits into
pytest-dev:mainfrom
cty-ut:fix/junitxml-setup-error-output
Draft

cty-ut wants to merge 2 commits into
pytest-dev:mainfrom
cty-ut:fix/junitxml-setup-error-output

Conversation

@cty-ut

@cty-ut cty-ut commented Oct 17, 2026 •

Copy link
Copy Markdown

With junit_logging=all and junit_log_passing_tests=false, a fixture setup error followed by a successful teardown produces an <error> in JUnit XML but loses the captured stdout, stderr, and logging output. The output is still present in the teardown report; write_captured_output() suppresses it because that individual phase passed.

Keep captured output when the testcase already contains an error. Output is still written at teardown, so cleanup diagnostics are included without writing the setup output twice. The existing call-failure handling is unchanged. This covers a setup-error case left outside the call-phase fix in #6274 and reproduces without third-party plugins or interlaced reports.

The regression test covers both XML families, both values of junit_log_passing_tests, and successful or failing cleanup. It checks that setup and teardown output from all three channels appears exactly once. Before the fix, the two setup-error/passing-teardown cases with logging suppression failed; the other six controls passed.

Validation:

  • tox -e linting,py313: both environments passed. Python 3.13: 4701 passed, 51 skipped, 15 xfailed, 5 xpassed, 2 warnings.

  • python -m pytest testing/test_junitxml.py -q: 159 passed on Python 3.12.

  • Independent setup-error reproduction tests: 4 passed after the fix.

  • git diff --check: passed.

  • Include regression tests.

  • Add the contributor to AUTHORS.

  • Allow maintainers to push and squash commits.

  • Add the changelog fragment changelog/15196.bugfix.rst.

  • Credit AI assistance in the commit's Co-authored-by trailer.

Prepared with Codex assistance, including investigation, implementation, and test execution. The commit credits the assistance with a Co-authored-by trailer.

cty-ut and others added 2 commits October 17, 2026 20:44
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Oct 17, 2026

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.

1 participant