【发布时间】:2017-09-11 11:36:10
【问题描述】:
我有以下代码:
class cutomTests(unittest.TestCase, moduleName.className):
def test_input_too_large(self):
'''className.functionName should fail with large input'''
self.assertRaises(moduleName.OutOfRangeError, self.functionName(4000)
我得到了以下结果:
======================================================================
ERROR: test_input_too_large (__main__.customTests)
className.functionName should fail with large input
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/user/workspace//ClassNameTests.py", line 37, in test_input_too_large
self.assertRaises(toRoman.OutOfRangeError, self.answer(4000))
File "/home/user/workspace/moduleName.py", line 47, in answer
raise OutOfRangeError()
OutOfRangeError
所以结果应该是正确的,因为引发了异常???
【问题讨论】:
标签: python unit-testing exception