0
我在python中運行以下單元測試,結果應該是正確的,但單元測試出錯了。Python單元測試以失敗告終
什麼是錯誤?
這是類考試我一定要
class Strategy:
_a = 0
_b = 0
_result = 0
def __init__(self, a, b):
try:
int(a)
int(b)
except ValueError:
raise ValueError()
self._a = a
self._b = b
這是我的單元測試
def test_invalideValue(self):
with self.assertRaises(ValueError) as cm:
StrategyAddition('A', 3)
self.assertEqual(cm.exception, ValueError())
這看跌
Failure
Traceback (most recent call last):
File "C:\Users\Michi\workspace_python\DesignPatternPython\Strategy\TestStrategy.py", line 24, in test_invalideValue
self.assertEqual(cm.exception, ValueError())
AssertionError: ValueError() != ValueError()