def test_register(self, case_list):
     self.my_HandleExcel = HandleExcel(file, 'register')
     request_result = do_request.send_request(
         case_list['method'],
         do_config.get_value('request', 'default_address') +
         case_list['url_path'], case_list['data'])
     actual_text = request_result.text
     actual_value = json.loads(actual_text)['code']
     actual = 'code: "{}",'.format(actual_value)
     result = case_list['expected']
     msg = case_list['title']
     try:
         self.assertEqual(result, actual, msg)
         print('{},执行结果为:{}'.format(msg, true_result))
         self.my_HandleExcel.write_result(case_list['case_id'] + 1, actual,
                                          true_result)
         do_logger.error("{}, 执行结果为: {}".format(msg, true_result))
     except AssertionError as e:
         print('具体异常为{}'.format(e))
         self.my_HandleExcel.write_result(case_list['case_id'] + 1, actual,
                                          fail_result)
         do_logger.error("{}, 执行结果为: {},具体异常为{}".format(
             msg, fail_result, e))
         raise e
Example #2
0
# cases_list = eval(cases_list)
case_list = {'case_id': 1, 'title': '使用不存在的手机号进行注册', 'url_path': '/member/register',
             'data': '{"mobilephone": "13786245301", "pwd": 123456, "regname": "刀刀"}', 'method': 'POST',
             'expected': 'code: "10001",', 'actual': None, 'result': None}
# print(type(case_list),case_list)
method = case_list['method']
url = do_config.get_value('request', 'default_address') + case_list['url_path']
datas = case_list['data']
datas = eval(datas)

# actual = do_request.send_request(case_list['method'],
#                                         do_config.get_value('request', 'default_address') + case_list['url_path'],
#                                         eval(case_list['data']))

print(type(method), method)
print(type(url), url)
print(type(datas), datas)
# print(actual)


request_result = do_request.send_request(case_list['method'],
                                         do_config.get_value('request', 'default_address') + case_list['url_path'],
                                         case_list['data'])
actual_text = request_result.text
actual_value = json.loads(actual_text)['code']
actual = 'code: "{}",'.format(actual_value)
do_request.request_close()
result = case_list['expected']
msg = case_list['title']
print(actual)