def test_add_two_one(self): res = MathMethod(1, 1).add() print("1+1的结果是:", res) try: self.assertEqual(1, res, '算法错误') except AssertionError as e: print('错误啦,断言错误{0}'.format(e)) raise e
def test_add_two_negative(self): res = MathMethod(-1, -2).add() print("-1+-2的结果是:", res)
def test_multi_two_negative(self): """两个负数相加""" res = MathMethod(-1, -2).multi() print("-1*-2的结果是:", res)
def test_add_two_zero(self): res = MathMethod(0, 0).add() print("0+0的结果是:", res)
def test_multi_two_zero(self): """两个0相加""" res = MathMethod(0, 0).multi() print("0*0的结果是", res)
def test_multi_two_positive(self): """两个正数相乘""" res = MathMethod(1, 1).multi() print("1*1的结果是:", res)
def test_add_two_negative(self): """两个负数相加""" res = MathMethod(-1, -2).add() print("-1+-2的结果是:", res) self.assertEqual(-3, res)
def test_add_two_zero(self): """两个0相加""" res = MathMethod(0, 0).add() print("0+0的结果是", res) self.assertEqual(1, res)
def test_add_two_positive(self): """两个正数相加""" res = MathMethod(1, 1).add() print("1+1的结果是:", res) # 加一个断言判断期望值与预期结果 一致通过,不一致失败 self.assertEqual(2, res)