I was checking the online documentation ofunittest.TestResult . If I understand correctly, an instance of this class have two iterable attributes: errors
and failures
which return instances of unittest.TestCase
. And then by using the unittest.TestCase.id()
method, one can obtain the absolute package path to the test_*
method (including its name) that was called and executed.
However, I didn't find any attribute in unittest.TestResult
allowing to find the list of successful tests (after running a unittest.TestSuite
).
So my question is how one should proceed in order to find them?
Finally, what I did was using inheritance. So I extended the unittest.TestResult
class and I added a new attribute, a list to track the succesful tests. The list is updated in the following method: wasSuccessful()
. Based on the documentation, there is no default implementation for this method so I overrod it in my extended class to achieve what I was looking for.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.