How to check test run results in nose2?

303 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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()