You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At first I thought --junitxml was the way to go but it seems like that is incompatible with the xdist plugin and also not documented much.
That's not true, pytest with xdist and the junitxml option work as expected (all our tests at work use both successfully). Can you post what error are you having, if any?
Then I thought pytest-json looked great, but it seems to break reading a setup.cfg file.
If so it might be a bug in pytest-json, could you please report the problem in the appropriate channel?
Is there a simple way to be able to collect the output of a py.test run in a machine readable format for easy reporting?
Besides junitxml there's also --result-log but that's been deprecated for some time, although we don't have a set timeline to remove it yet.
the basic answer is - there is absolutely no sanely parsable and complete output for pytest
the problems with xdist vs junitxml probably relate to the fact that transferred trackebacks are basically "broken" and lead to different junitxml output
All of the solutions speak of tools that insert themselves in the middle of a test run as it executes - not after the fact. So if all you have is the console output, and you don't have access to the machine that's running the pytest job - like, in an environment where everything is containerized and shuttled off to a Jenkins job to run - seems like you're basically screwed.
yes it would be a good thing to be able to output a machine readable format by using a simple cli option. Like python -m pytest -h whatever
I wrote a plugin a while back that addresses some shortcomings I saw in the existing solutions. It can produce JSON output as per the specified format. The command-line to do so would be
pytest --recap
There is also a discussion on that repo's README that talks about the various options (that I knew of at the time) for outputting machine-readable session files.
Activity
nicoddemus commentedon Mar 14, 2017
Hi,
That's not true,
pytestwithxdistand thejunitxmloption work as expected (all our tests at work use both successfully). Can you post what error are you having, if any?If so it might be a bug in
pytest-json, could you please report the problem in the appropriate channel?Besides
junitxmlthere's also--result-logbut that's been deprecated for some time, although we don't have a set timeline to remove it yet.emin63 commentedon Mar 14, 2017
Thanks for the quick response.
Perhaps I was confused about junitxml. Looking at http://doc.pytest.org/en/latest/usage.html, it seems like there is a comment that it is experimental and it does not work with pytest-xdist. Maybe that was referring to record_xml_property and not junitxml?
Issue filed for pytest-json at mattcl/pytest-json#2.
If
junitxmlis the way to go, could you point me to any tools or specifications for the output format?Thanks again.
Clarify that record_xml_property is experimental, not junitxml
nicoddemus commentedon Mar 14, 2017
Exactly. 😁
I have updated the docs to make the distinction clearer, see #2307.
Thanks, appreciate it.
If you execute it with a few tests the format should be self-explanatory, but you can see the official schema here.
RonnyPfannschmidt commentedon Mar 14, 2017
the basic answer is - there is absolutely no sanely parsable and complete output for pytest
the problems with xdist vs junitxml probably relate to the fact that transferred trackebacks are basically "broken" and lead to different junitxml output
emin63 commentedon Jul 15, 2017
Just an update for anyone coming here to parse pytest output:
xmltodictmodule. If you really want json, you could just dump the result to json usingjson.dumps.Thanks.
kaczmarj commentedon Jan 22, 2021
i am wondering how to parse pytest output as well. https://github.com/pytest-dev/pytest-reportlog seems to be the right tool for me.
jeffwright13 commentedon Dec 19, 2022
All of the solutions speak of tools that insert themselves in the middle of a test run as it executes - not after the fact. So if all you have is the console output, and you don't have access to the machine that's running the pytest job - like, in an environment where everything is containerized and shuttled off to a Jenkins job to run - seems like you're basically screwed.
RonnyPfannschmidt commentedon Dec 20, 2022
exactly, as intended - if youwant parsable output, make sure you get an artifact for that
RonnyPfannschmidt commentedon Dec 20, 2022
that being said, it might be interesting to have normal ux on stderr and reportlog on stdout
nimdanor commentedon Nov 22, 2025
yes it would be a good thing to be able to output a machine readable format by using a simple cli option. Like
python -m pytest -h whatever
jeffwright13 commentedon Nov 22, 2025
I wrote a plugin a while back that addresses some shortcomings I saw in the existing solutions. It can produce JSON output as per the specified format. The command-line to do so would be
There is also a discussion on that repo's README that talks about the various options (that I knew of at the time) for outputting machine-readable session files.
nicoddemus commentedon Nov 22, 2025
@nimdanor have you seen https://github.com/pytest-dev/pytest-reportlog? Does it not fit your needs?
nimdanor commentedon Nov 22, 2025
thanks i will use reportlog