Unit test script returns exit code = 0 even if tests fail

后端 未结 2 1366
悲&欢浪女
悲&欢浪女 2020-12-14 07:19

My testing script looks as follows:

import os
import sys
from unittest import defaultTestLoader as loader, TextTestRunner

path_to_my_project = os.path.dirnam         


        
2条回答
  •  盖世英雄少女心
    2020-12-14 08:18

    The code is not using unittest.main. You need to check the result using TestResult.wasSuccessful and call sys.exit manually.

    import sys
    
    ....
    
    ret = not runner.run(suite).wasSuccessful()
    sys.exit(ret)
    

提交回复
热议问题