【发布时间】:2011-11-29 05:10:51
【问题描述】:
为什么即使两个函数都返回相同的值,测试用例也会失败?
import unittest
def first():
return 4312
def second():
return 4312
class testcase(unittest.TestCase):
def case1(self):
self.assertEqual(first(),second())
def test():
print first(),second()
unittest.main()
我正在执行 test() 函数
我得到的输出是:
Ran 0 tests in 0.000s
OK
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
test()
File "C:/Users/ashutosh.rd/Desktop/x.py", line 15, in test
File "C:\Python27\lib\unittest\main.py", line 95, in __init__
self.runTests()
File "C:\Python27\lib\unittest\main.py", line 231, in runTests
sys.exit(not self.result.wasSuccessful())
SystemExit: False
【问题讨论】:
-
对我有用,虽然我必须编辑这个脚本才能让它作为测试运行。请编辑以包含一个有效的实际脚本,以及运行此脚本的完整结果。
-
到底是怎么失败的?你在跑什么,python 回馈什么是错的?
标签: python unit-testing