With unittest
I can check if there were failed tests during test run like this:
import unittest
all_tests = unittest.defaultTestLoader.discover('path-to-tests')
results = unittest.TextTestRunner().run(all_tests)
if results.wasSuccessful():
do_something()
else:
do_something_else()
How to do the same with nose2
?
Finally found an answer.
import nose2
test_run = nose2.discover(argv = ['-s', 'path-to-tests'], exit = False)
if test_run.result.wasSuccessful():
do_something()
else:
do_something_else()