0

我可以检查在unittest测试运行期间是否有失败的测试,如下所示:

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

如何做同样的事情nose2

4

1 回答 1

0

终于找到答案了。

import nose2

test_run = nose2.discover(argv = ['-s', 'path-to-tests'], exit = False)
if test_run.result.wasSuccessful():
    do_something()
else:
    do_something_else()
于 2015-12-02T18:40:06.507 回答