jeudi 23 juillet 2015

Adding arbitrary details in pytest

Is it possible in pytest to record arbitrary data from test executions.

For example:

import random
class TestSomeStuff:

   def test_something(self):
       r1 = random.random()
       r2 = random.random()

       ## I'd like to do something which could make these
       #  values accessible later, so that they could be
       #  put into a report
       self.r1 = r1
       self.r2 = r2
       ###

       assert r1 < r2

I'd like to save details about the test, which could be put into a report. I'd like the report to be able to include these details, regardless of whether or not the test failed.

Can pytest be made to report arbitrary details about a test?

Aucun commentaire:

Enregistrer un commentaire