Is it possible to get the results of a test (i.e. whether all assertions have passed) in a tearDown() method? I\'m running Selenium scripts, and I\'d like to do some reporti
If you are using Python2 you can use the method _resultForDoCleanups
. This method return a TextTestResult object:
You can use this object to check the result of your tests:
def tearDown(self):
if self._resultForDoCleanups.failures:
...
elif self._resultForDoCleanups.errors:
...
else:
#Success
If you are using Python3 you can use _outcomeForDoCleanups
:
def tearDown(self):
if not self._outcomeForDoCleanups.success:
...