Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Processing pytest test results at runtime

Tags:

python

pytest

So I have have pytest run my tests and that's great, but I want to actually do something with the test results. I was using unittest, and that gives me a swanky results object that I can process after the tests have run. Pytest just seems to give me a big text dump - writing a parser for that sounds mind-numbingly boring.

How do I get the results into something I can use? I must be missing something.

btw - I'm running my tests using pytest.main(), not via the command line py.test. I was hoping to have some sort of result object I can interact with at runtime. I realize I can write results to disk, read from disk, parse said results and then act on results - but it seems like those disk operations are just extra steps I should be able to avoid.

like image 247
Isaac Avatar asked Sep 02 '25 09:09

Isaac


1 Answers

py.test result files are not really meant to be human readable. I'm not sure if there is a third-party parser for them or not. They are meant to be read by a continuous integration server like Hudson or Travis-ci. As @limelights said you get the xml files for these services with the --junitxml=path flag. More here. or with the --resultlog=path flag. More here.

like image 93
Charlie Andrews Avatar answered Sep 04 '25 21:09

Charlie Andrews