[TIP] add docstring field to junit xml file output

Mathew, Vinay Vinay.Mathew at dolby.com
Fri Jul 12 01:09:43 PDT 2013


We are using pytest to develop and run our tests written in python. Our framework is such that we use the -junitxml results file to do some post processing. In this context we would like to have the docstrings from every test function as part of the output junit xml file.

Could somebody give us a pointer as to the best approach to do this. What we were looking at doing is as follows:
1. Run the tests and generate the junit xml file.
2. Parse the test scripts and extract the docstrings from every test function.
3. Merge these as an additional attribute to each of the tests in the junit xml file.

The way I am seeing it is that this is postprocessing of the junit xml file. Is there an easier way to do this during the test run and generation of the junit xml file itself? If so where would I have to look add this? Is it through some hooks that we can use?

Vinay Mathew

More information about the testing-in-python mailing list