def test_zero_add(self):
     real_result = Arithmetic(0, 0).add()
     expect_result = 0
     msg = '零和零相加'
     try:
         self.assertEqual(expect_result, real_result, msg)
         self.file.write('\n{},执行结果为:{}\n'.format(msg, 'Pass'))
     except AssertionError as e:
         print('具体异常为{}'.format(e))
         self.file.write('\n{},执行结果为:{}\n具体异常为:{}\n'.format(msg, 'Fail', e))
         raise e
 def test_positive_negative_add(self):
     real_result = Arithmetic(13, -2).add()
     expect_result = 11
     msg = '正数和负数相加'
     try:
         self.assertEqual(expect_result, real_result, msg)
         self.file.write('\n{},执行结果为:{}\n'.format(msg, 'Pass'))
     except AssertionError as e:
         print('具体异常为{}'.format(e))
         self.file.write('\n{},执行结果为:{}\n具体异常为:{}\n'.format(msg, 'Fail', e))
         raise e
Example #3
0
 def test_multiply(self):
     self.ws_2 = self.file_2['multiply']
     my_excel = HandleExcel(self.file_name_2, 'multiply')
     for index, case_list in enumerate(my_excel.get_case()):
         real_result = Arithmetic(case_list['l_data'],
                                  case_list['r_data']).multiply()
         expect_result = case_list['expected']
         msg = case_list['title']
         try:
             self.assertEqual(expect_result, real_result, msg)
             print('\n{},执行结果为:{}\n'.format(msg, 'Pass'))
             self.file_1.write('\n{},执行结果为:{}\n'.format(msg, 'Pass'))
             self.ws_2.cell(index + 2, 6).value = real_result
             self.ws_2.cell(index + 2, 7).value = 'Pass'
         except AssertionError as e:
             print('具体异常为{}'.format(e))
             self.file_1.write('\n{},执行结果为:{}\n具体异常为:{}\n'.format(
                 msg, 'Fail', e))
             self.ws_2.cell(index + 2, 6).value = real_result
             self.ws_2.cell(index + 2, 7).value = 'Fail'
             raise e