python 单元测试(unittest) 运行无效解决方案

python 单元测试(unittest) 运行无效解决方案

  1. 防止模块重复运行

    if __name__=="__main__":
    unittest.mai
    
  2. 所有 unittest.TestCase 定义的 测试用例命名 都要以 test 开头,因为此约定 告诉测试器,哪些方法代表测试

具体代码表现参考:
https://stackoverflow.com/questions/57589837/why-are-unit-tests-invalid

https://stackoverflow.com/questions/13626524/unit-test-not-running

发布了130 篇原创文章 · 获赞 91 · 访问量 13万+

猜你喜欢

转载自blog.csdn.net/Chad97/article/details/99990270