Skip to content

junitxml: make record_xml_attribute work with pytest-xdist - #15492

Open
Mohanad49 wants to merge 2 commits into
pytest-dev:mainfrom
Mohanad49:fix-8654-xdist-xml-attribute
Open

Mohanad49 wants to merge 2 commits into
pytest-dev:mainfrom
Mohanad49:fix-8654-xdist-xml-attribute

Conversation

@Mohanad49

Copy link
Copy Markdown

Closes #8654.

I traced the missing attributes to where record_xml_attribute writes them. It writes straight to LogXML, which only exists on the controller when xdist is running. The fixture runs on a worker, so those calls used to do nothing there.

I now keep the attributes on the test item and send a copy as strings on each test report. The controller reads them from the report before applying the existing XML escaping and xunit family rules. The experimental warning still appears, and workers now also emit the xunit2 compatibility warning when JUnit XML is enabled.

There's one output change even without xdist. If the test fails and its teardown also errors, attributes recorded before teardown now appear on both <testcase> elements in xunit1. Attributes recorded during teardown appear on the teardown error element. Does that match what you'd want for a test with two testcase elements?

  • I ran the same focused selection before and after the original fix. It went from 4 failed and 6 passed to 10 passed. After adding the worker warning assertion, I ran 13 focused cases and all passed.
  • I tried four mutations: ignoring the attributes on the controller, leaving them off the report, requiring a local LogXML again, and passing raw values instead of strings. Both xdist regression cases failed for each mutation when I reran them against the final code.
  • The original full run recorded 4,768 passed, 55 skipped, 15 xfailed, 5 xpassed, 2 warnings, 1 failed, and 1 error. My full rerun with the warning change recorded 4,770 passed, 53 skipped, 15 xfailed, 5 xpassed, 2 warnings, 1 failed, and 1 error.
  • I reran those two tests on the clean base at b5b89d99e with -p no:cacheprovider and got the same failure and error. test_fixture_doctest_skip_has_line_number failed because the reported line number was None. test_cache_makedir errored at setup because the cache fixture was unavailable. I also checked that the cache test passes with the provider enabled on both revisions.

Carry recorded attributes on test reports so the controller can write them
to JUnit XML. Keep xUnit2 filtering and warn when the fixture is used on a
worker with that family.

Co-authored-by: Claude Opus 5.5 (Claude Code) <[email protected]>
Assisted-by: Codex CLI (gpt-6.2-sol)
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Nov 28, 2026
There is no fixture:: entry for record_xml_attribute in the reference docs, so the :fixture: role failed the docs build (warnings are errors).

Co-authored-by: Claude Opus 5.5 (Claude Code) <[email protected]>

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.

record_xml_attribute not visible in JUnit XML when using pytest-xdist

1 participant