Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to collect data results in pytest using junitxml?

Tags:

Let's use the following code (conftest.py) :

import random
def test_val():
    value = random.random()
    assert value < 0.5

Running py.test --junitxml=result.xml conftest.py generates result.xml (when the test passes):

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="0" failures="0" name="" skips="0" tests="1" time="0.047">
<testcase classname="conftest" name="test_val" time="0.0"/>
</testsuite>

Now. What I'd like to be able to do is to store the value generated by test_val() in results.xml. Is there a way to do it ? I can't seem to find anything related in pytest doc.