例外,我有以下代碼:tyring來測試使用Python單元測試
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
所以結果應右路傳中,因爲引發異常? ??
兩者有什麼,什麼情況下做經理的區別 – Umar