示例#1
0
 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
示例#2
0
 def test_add_two_negative(self):
     res = MathMethod(-1, -2).add()
     print("-1+-2的结果是:", res)
示例#3
0
 def test_multi_two_negative(self):
     """两个负数相加"""
     res = MathMethod(-1, -2).multi()
     print("-1*-2的结果是:", res)
示例#4
0
 def test_add_two_zero(self):
     res = MathMethod(0, 0).add()
     print("0+0的结果是:", res)
示例#5
0
 def test_multi_two_zero(self):
     """两个0相加"""
     res = MathMethod(0, 0).multi()
     print("0*0的结果是", res)
示例#6
0
 def test_multi_two_positive(self):
     """两个正数相乘"""
     res = MathMethod(1, 1).multi()
     print("1*1的结果是:", res)
示例#7
0
 def test_add_two_negative(self):
     """两个负数相加"""
     res = MathMethod(-1, -2).add()
     print("-1+-2的结果是:", res)
     self.assertEqual(-3, res)
示例#8
0
 def test_add_two_zero(self):
     """两个0相加"""
     res = MathMethod(0, 0).add()
     print("0+0的结果是", res)
     self.assertEqual(1, res)
示例#9
0
 def test_add_two_positive(self):
     """两个正数相加"""
     res = MathMethod(1, 1).add()
     print("1+1的结果是:", res)
     # 加一个断言判断期望值与预期结果  一致通过,不一致失败
     self.assertEqual(2, res)