Getting Python's unittest results in a tearDown() method

前端 未结 13 1329
野的像风
野的像风 2020-11-28 22:40

Is it possible to get the results of a test (i.e. whether all assertions have passed) in a tearDown() method? I\'m running Selenium scripts, and I\'d like to do some reporti

13条回答
  •  离开以前
    2020-11-28 23:10

    Python 2.7.

    You can also get result after unittest.main():

    t = unittest.main(exit=False)
    print t.result
    

    or use suite:

    suite.addTests(tests)
    result = unittest.result.TestResult()
    suite.run(result)
    print result
    

提交回复
热议问题