forked from DxvLwRYF/apiAutoTest
1 line
5.8 KiB
JSON
1 line
5.8 KiB
JSON
{"name": "调试运算新功能", "status": "failed", "statusDetails": {"message": "AssertionError: 断言失败 -|- 实际结果:None || 预期结果: 成功", "trace": "cls = <class 'tools.data_process.DataProcess'>\nresponse = {'data': {'create_time': 1611727380, 'id': 513, 'role_id': -1, 'username': 'tery'}, 'meta': {'msg': '创建成功', 'status': 201}}\nexpect_str = '{\"$.msg\": \"成功\"}'\n\n @classmethod\n def assert_result(cls, response: dict, expect_str: str):\n \"\"\" 预期结果实际结果断言方法\n :param response: 实际响应结果\n :param expect_str: 预期响应内容,从excel中读取\n return None\n \"\"\"\n # 后置sql变量转换\n expect_str = rep_expr(expect_str, DataProcess.response_dict)\n expect_dict = convert_json(expect_str)\n index = 0\n for k, v in expect_dict.items():\n # 获取需要断言的实际结果部分\n actual = extractor(response, k)\n index += 1\n logger.info(f'第{index}个断言,实际结果:{actual} | 预期结果:{v} \\n断言结果 {actual == v}')\n allure_step(f'第{index}个断言', f'实际结果:{actual} = 预期结果:{v}')\n try:\n> assert actual == v\nE AssertionError\n\ntools\\data_process.py:118: AssertionError\n\nDuring handling of the above exception, another exception occurred:\n\ncases = ['case_017', '调试运算新功能', 'users/', '读', 'post', 'data', ...]\n\n def test_main(cases): # 不使用数据库功能\n # 发送请求\n response, expect, sql = BaseRequest.send_request(cases)\n # 断言操作\n> DataProcess.assert_result(response, expect)\n\ntest\\test_api.py:35: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\ncls = <class 'tools.data_process.DataProcess'>\nresponse = {'data': {'create_time': 1611727380, 'id': 513, 'role_id': -1, 'username': 'tery'}, 'meta': {'msg': '创建成功', 'status': 201}}\nexpect_str = '{\"$.msg\": \"成功\"}'\n\n @classmethod\n def assert_result(cls, response: dict, expect_str: str):\n \"\"\" 预期结果实际结果断言方法\n :param response: 实际响应结果\n :param expect_str: 预期响应内容,从excel中读取\n return None\n \"\"\"\n # 后置sql变量转换\n expect_str = rep_expr(expect_str, DataProcess.response_dict)\n expect_dict = convert_json(expect_str)\n index = 0\n for k, v in expect_dict.items():\n # 获取需要断言的实际结果部分\n actual = extractor(response, k)\n index += 1\n logger.info(f'第{index}个断言,实际结果:{actual} | 预期结果:{v} \\n断言结果 {actual == v}')\n allure_step(f'第{index}个断言', f'实际结果:{actual} = 预期结果:{v}')\n try:\n assert actual == v\n except AssertionError:\n> raise AssertionError(f'断言失败 -|- 实际结果:{actual} || 预期结果: {v}')\nE AssertionError: 断言失败 -|- 实际结果:None || 预期结果: 成功\n\ntools\\data_process.py:120: AssertionError"}, "steps": [{"name": "请求地址", "status": "passed", "attachments": [{"name": "请求地址", "source": "5d5752c4-6d8b-41bd-b8bd-1ab8a2f60c9d-attachment.txt", "type": "text/plain"}], "start": 1611727380764, "stop": 1611727380764}, {"name": "请求头", "status": "passed", "attachments": [{"name": "请求头", "source": "e279ab21-808f-4e91-b1c0-67d5c515c694-attachment.txt", "type": "text/plain"}], "start": 1611727380764, "stop": 1611727380765}, {"name": "请求参数", "status": "passed", "attachments": [{"name": "请求参数", "source": "1dd17f61-8d37-4f8c-bb2f-092f163bb81c-attachment.txt", "type": "text/plain"}], "start": 1611727380765, "stop": 1611727380765}, {"name": "上传文件", "status": "passed", "attachments": [{"name": "上传文件", "source": "c1c6790e-fe0a-4899-8e25-92183dc47c16-attachment.txt", "type": "text/plain"}], "start": 1611727380766, "stop": 1611727380766}, {"name": "响应耗时(s)", "status": "passed", "attachments": [{"name": "响应耗时(s)", "source": "3030c2ca-4cdb-441a-93ff-c9394dee5c19-attachment.txt", "type": "text/plain"}], "start": 1611727380929, "stop": 1611727380930}, {"name": "响应内容", "status": "passed", "attachments": [{"name": "响应内容", "source": "bb3f6174-965c-4871-a393-5731dd6cc543-attachment.txt", "type": "text/plain"}], "start": 1611727380930, "stop": 1611727380930}, {"name": "存储实际响应", "status": "passed", "attachments": [{"name": "存储实际响应", "source": "a4f70132-3df2-41ab-ba5e-2b1f68bae996-attachment.txt", "type": "text/plain"}], "start": 1611727380931, "stop": 1611727380931}, {"name": "第1个断言", "status": "passed", "attachments": [{"name": "第1个断言", "source": "17790e3d-c435-4879-92e0-fe9a11838948-attachment.txt", "type": "text/plain"}], "start": 1611727380932, "stop": 1611727380933}], "attachments": [{"name": "stderr", "source": "42ffe193-6d56-4543-8bb3-0165021b4957-attachment.txt", "type": "text/plain"}], "parameters": [{"name": "cases", "value": "['case_017', '调试运算新功能', 'users/', '读', 'post', 'data', '', '{\"username\": \"tery\",\"password\": \"eval`1+2`\"}', '', '{\"$.msg\": \"成功\"}']"}], "start": 1611727380763, "stop": 1611727380933, "uuid": "2ed0fb68-d99b-423c-9533-e15a1d376f09", "historyId": "25f6ba9e78828713a480fcdbed4cfa82", "testCaseId": "881516e7ef2e2aa5436f6a3c3e6a5bcb", "fullName": "test.test_api#test_main", "labels": [{"name": "parentSuite", "value": "test"}, {"name": "suite", "value": "test_api"}, {"name": "host", "value": "LAPTOP-FR8LEA9G"}, {"name": "thread", "value": "5708-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "test.test_api"}]} |