简体   繁体   中英

How to check test run results in nose2?

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM