Python中的Unittest返回False,尽管测试正常?
我的代码:Python中的Unittest返回False,尽管测试正常?,python,Python,我的代码: import unittest from mylib import myfunc class test_mylib(unittest.TestCase): def test_myfunc(self): self.assertTrue(myfunc(10)==50) if __name__ == '__main__': unittest.main() 它将测试显示为OK,但同时返回False。如果测试正常,是否有方法返回True 输出: OK
import unittest
from mylib import myfunc
class test_mylib(unittest.TestCase):
def test_myfunc(self):
self.assertTrue(myfunc(10)==50)
if __name__ == '__main__':
unittest.main()
它将测试显示为OK,但同时返回False。如果测试正常,是否有方法返回True
输出:
OK
Exit code: False
在Unix上,进程退出代码
0
表示成功。我猜无论您使用什么工具来运行测试,都会将其解释为False