Example #1
0
 def test_add_positive_nagetive(self):  #一正一负相加
     result = MathMethod().add(self.a, self.b)
     try:
         self.assertEqual(self.excepted, result)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         raise e
     print('一正一负相加的结果是{}'.format(result))
Example #2
0
 def test_sub_two_positive_nagetive(self):  #一正一负相减
     result = MathMethod().sub(self.test_data[2][0], self.test_data[2][1])
     excepted = -6
     try:
         self.assertEqual(excepted, result)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         raise e
     print('一正一负相减的结果是{}'.format(result))
Example #3
0
 def test_sub_two_zheng(self):  #两个正数相减
     result = MathMethod().sub(self.test_data[0][0], self.test_data[0][1])
     excepted = 3
     try:
         self.assertEqual(result, excepted)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         raise e
     print('两个正数相减的结果是{}'.format(result))
Example #4
0
 def test_add_two_nagetive(self):  #两个负数相加
     result = MathMethod().add(self.a, self.b)
     try:
         self.assertEqual(self.excepted, result)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         #抛出异常
         raise e
     print('两个负数相加的结果是{}'.format(result))
Example #5
0
 def test_abs_two_positive_nagetive(self):  #一正一负数的绝对值
     result = MathMethod().a_b_s(self.test_data[2][0], self.test_data[2][1])
     excepted = 9
     try:
         self.assertEqual(excepted, result)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         raise e
     print('一正一负数的绝对值是{}'.format(result))
Example #6
0
 def test_abs_two(self):  #两个正数的绝对值
     result = MathMethod().a_b_s(self.test_data[0][0], self.test_data[0][1])
     excepted = 1
     try:
         self.assertEqual(excepted, result)
     except AssertionError as e:
         print('断言出错:{}'.format(e))
         raise e
     print('两个正数的绝对值是{}'.format(result))
Example #7
0
    def test_add(self):  #两个0相加
        result = MathMethod().add(self.a, self.b)
        try:
            self.assertEqual(self.excepted, result)
            testresult = 'pass'  #如果代码进入try,那么用例通过
        except AssertionError as e:
            testresult = 'failed'  #如果代码进入到except了里面,用例就不通过
            print('断言出错:{}'.format(e))  #断言 判断期望结果和实际结果是否一致
            raise e

        finally:
            #写回结果
            self.excel.write_back(self.case_id + 1, 6, result)  #写回测试的实际结果
            self.excel.write_back(self.case_id + 1, 7,
                                  testresult)  #写回测试结论,到底是通过还是不通过