1 |
- {"name": "登录成功", "status": "broken", "statusDetails": {"message": "Exception: 规范yaml文件standard_yaml异常:Traceback (most recent call last):\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 170, in assert_result\n self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 204, in assert_contains\n error_log(\"断言失败:返回结果中不包含\" + str(value))\n File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\n raise Exception(message)\nException: 断言失败:返回结果中不包含True\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 148, in standard_yaml\n self.assert_result(arg_names['validate'], return_json, return_code)\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 183, in assert_result\n error_log(\"断言assert_result异常:%s\" % str(traceback.format_exc()))\n File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\n raise Exception(message)\nException: 断言assert_result异常:Traceback (most recent call last):\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 170, in assert_result\n self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 204, in assert_contains\n error_log(\"断言失败:返回结果中不包含\" + str(value))\n File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\n raise Exception(message)\nException: 断言失败:返回结果中不包含True", "trace": "self = <common.request_util.RequestUtil object at 0x0000022934920490>\nyq_result = [{'contains': True}]\nsj_result = {'code': '-1', 'data': None, 'msg': '验证码错误!', 'success': False}\nreturn_code = 200\n\n def assert_result(self, yq_result, sj_result, return_code):\n try:\n logs(\"预期结果:%s\" % yq_result)\n logs(\"实际结果:%s\" % json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n \n # print(yq_result)\n for yq in yq_result:\n for key, value in yq.items():\n # print(key, value)\n if key == \"equals\":\n self.assert_equals(value, sj_result, return_code)\n \n elif key == \"contains\":\n> self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n\ncommon\\request_util.py:170: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nself = <common.request_util.RequestUtil object at 0x0000022934920490>\nvalue = True\nsj_result = {'code': '-1', 'data': None, 'msg': '验证码错误!', 'success': False}\n\n def assert_contains(self, value, sj_result):\n \n if str(value).replace(\"{\", \"\").replace(\"}\", \"\") not in str(sj_result):\n> error_log(\"断言失败:返回结果中不包含\" + str(value))\n\ncommon\\request_util.py:204: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nmessage = '断言失败:返回结果中不包含True'\n\n def error_log(message):\n LoggerUtil().create_log().error(message)\n> raise Exception(message)\nE Exception: 断言失败:返回结果中不包含True\n\ncommon\\log_util.py:68: Exception\n\nDuring handling of the above exception, another exception occurred:\n\nself = <common.request_util.RequestUtil object at 0x0000022934920490>\narg_names = {'extract': {'token': '\"token\":\"(.*?)\"'}, 'request': {'json': {'captcha': 'youthcq', 'captchaKey': 'wwohetlyfcuswjcxey...344F4A57654249677779546631612B6E4B724E334C6B4B695A336A574D3D', 'scope': 'WEB', ...}}, 'validate': [{'contains': True}]}\n\n def standard_yaml(self, arg_names):\n try:\n logs(\"--------接口测试开始--------\")\n arg_names_keys = arg_names.keys()\n # 判断一级关键字是否存在:name,request,validate\n if \"name\" in arg_names_keys and \"request\" in arg_names_keys and \"validate\" in arg_names_keys:\n # 判断requests下面是否包含method,url\n request_keys = arg_names['request'].keys()\n if \"method\" in request_keys and \"url\" in request_keys:\n logs(\"yaml框架检查基本通过\")\n # pop返回该值,并删除\n name = arg_names.pop(\"name\")\n method = arg_names['request'].pop(\"method\")\n url = arg_names['request'].pop(\"url\")\n # 发送请求\n res = self.send_request(name, method, url, **arg_names['request'])\n # print(json.loads(json.dumps(res.json()).replace(r\"\\\\\", \"\\\\\")))\n return_text = res.text\n # print(return_text)\n return_json = \"\"\n return_code = res.status_code\n # 提取值并写入extract.yaml文件里面\n try:\n return_json = res.json()\n except Exception as e:\n error_log(\"返回结果不是json格式,不能用这种方法\")\n if \"extract\" in arg_names_keys:\n for key, value in arg_names['extract'].items():\n if \"(.*?)\" in value or \"(.+?)\" in value: # 正则\n # print(\"-------\"+ value)\n zz_value = re.search(value, return_text)\n if zz_value:\n extract_value = {key: zz_value.group(1)}\n write_yaml(extract_value)\n else: # jsonpath\n # print(\"+++++\"+value)\n js_value = jsonpath.jsonpath(return_json, value)\n if js_value:\n extract_value = {key: js_value[0]}\n write_yaml(extract_value)\n try:\n return_json = res.json()\n \n data = return_json[\"data\"][\"result\"]\n for i in range(len(data)):\n write_yaml_projectCode({(\"projectCode\" + str(i)): data[i]['projectCode']})\n \n except Exception as e:\n pass\n \n # 断言结果\n> self.assert_result(arg_names['validate'], return_json, return_code)\n\ncommon\\request_util.py:148: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nself = <common.request_util.RequestUtil object at 0x0000022934920490>\nyq_result = [{'contains': True}]\nsj_result = {'code': '-1', 'data': None, 'msg': '验证码错误!', 'success': False}\nreturn_code = 200\n\n def assert_result(self, yq_result, sj_result, return_code):\n try:\n logs(\"预期结果:%s\" % yq_result)\n logs(\"实际结果:%s\" % json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n \n # print(yq_result)\n for yq in yq_result:\n for key, value in yq.items():\n # print(key, value)\n if key == \"equals\":\n self.assert_equals(value, sj_result, return_code)\n \n elif key == \"contains\":\n self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\n \n elif key == 'db_equals':\n self.database_assert(value, sj_result)\n \n else:\n error_log(\"框架暂时不支持此框架断言\")\n logs(\"接口测试成功\")\n \n logs(\"------接口测试结束————————\\n\")\n except Exception as e:\n logs(\"接口测试失败!!!\")\n logs(\"------接口测试结束————————\")\n> error_log(\"断言assert_result异常:%s\" % str(traceback.format_exc()))\n\ncommon\\request_util.py:183: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nmessage = '断言assert_result异常:Traceback (most recent call last):\\n File \"D:\\\\zdh\\\\pythonProject\\\\common\\\\request_util.py\", line ...thonProject\\\\common\\\\log_util.py\", line 68, in error_log\\n raise Exception(message)\\nException: 断言失败:返回结果中不包含True\\n'\n\n def error_log(message):\n LoggerUtil().create_log().error(message)\n> raise Exception(message)\nE Exception: 断言assert_result异常:Traceback (most recent call last):\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 170, in assert_result\nE self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 204, in assert_contains\nE error_log(\"断言失败:返回结果中不包含\" + str(value))\nE File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\nE raise Exception(message)\nE Exception: 断言失败:返回结果中不包含True\n\ncommon\\log_util.py:68: Exception\n\nDuring handling of the above exception, another exception occurred:\n\nself = <test_case.qccq.test_allAPI2.TestAPI object at 0x00000229348E9F00>\narg_names = {'extract': {'token': '\"token\":\"(.*?)\"'}, 'request': {'json': {'captcha': 'youthcq', 'captchaKey': 'wwohetlyfcuswjcxey...344F4A57654249677779546631612B6E4B724E334C6B4B695A336A574D3D', 'scope': 'WEB', ...}}, 'validate': [{'contains': True}]}\n\n> ???\n\nD:\\zdh\\pythonProject\\cwtcase\\qccq\\test_allAPI2.py:18: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\ncommon\\request_util.py:154: in standard_yaml\n error_log(\"规范yaml文件standard_yaml异常:%s\" % str(traceback.format_exc()))\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n\nmessage = '规范yaml文件standard_yaml异常:Traceback (most recent call last):\\n File \"D:\\\\zdh\\\\pythonProject\\\\common\\\\request_util.py\",...onProject\\\\common\\\\log_util.py\", line 68, in error_log\\n raise Exception(message)\\nException: 断言失败:返回结果中不包含True\\n\\n'\n\n def error_log(message):\n LoggerUtil().create_log().error(message)\n> raise Exception(message)\nE Exception: 规范yaml文件standard_yaml异常:Traceback (most recent call last):\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 170, in assert_result\nE self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 204, in assert_contains\nE error_log(\"断言失败:返回结果中不包含\" + str(value))\nE File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\nE raise Exception(message)\nE Exception: 断言失败:返回结果中不包含True\nE \nE During handling of the above exception, another exception occurred:\nE \nE Traceback (most recent call last):\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 148, in standard_yaml\nE self.assert_result(arg_names['validate'], return_json, return_code)\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 183, in assert_result\nE error_log(\"断言assert_result异常:%s\" % str(traceback.format_exc()))\nE File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\nE raise Exception(message)\nE Exception: 断言assert_result异常:Traceback (most recent call last):\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 170, in assert_result\nE self.assert_contains(value, json.loads(json.dumps(sj_result).replace(r\"\\\\\", \"\\\\\")))\nE File \"D:\\zdh\\pythonProject\\common\\request_util.py\", line 204, in assert_contains\nE error_log(\"断言失败:返回结果中不包含\" + str(value))\nE File \"D:\\zdh\\pythonProject\\common\\log_util.py\", line 68, in error_log\nE raise Exception(message)\nE Exception: 断言失败:返回结果中不包含True\n\ncommon\\log_util.py:68: Exception"}, "attachments": [{"name": "log", "source": "5e796740-7879-4c35-a9c2-a6a47ebf67a0-attachment.txt", "type": "text/plain"}], "parameters": [{"name": "arg_names", "value": "{'name': '登录成功', 'request': {'method': 'post', 'url': '/service-sysmgr/LoginController/login', 'json': {'captcha': 'youthcq', 'captchaKey': 'wwohetlyfcuswjcxeyglkpxl', 'password': '5856464E5731466E547A4D794D6C2B42334973312B784D3561584E4264726F487532746F37664C6F70326F47752B6F585043426543704356777A59717065774A6F423439385659426F6668716D496C75484A344F54416764676668596F6478554C6365643255793742736B56714B6271644858777675724F6D3959794667356D455071796C7858776D586D72672B344F4A57654249677779546631612B6E4B724E334C6B4B695A336A574D3D', 'scope': 'WEB', 'username': '17723565637'}}, 'extract': {'token': '\"token\":\"(.*?)\"'}, 'validate': [{'contains': True}]}"}], "start": 1706516655290, "stop": 1706516655376, "uuid": "720e1735-b2d7-4347-a65a-c211f14e6d51", "historyId": "6cbf617ea7dd85e467e0f78500893638", "testCaseId": "a73eec0cc53d52f37a66f88755cf30b1", "fullName": "test_case.qccq.test_allAPI2.TestAPI#test_001_登录接口", "labels": [{"name": "epic", "value": "青春重庆"}, {"name": "feature", "value": "用户管理模块"}, {"name": "parentSuite", "value": "test_case.qccq"}, {"name": "suite", "value": "test_allAPI2"}, {"name": "subSuite", "value": "TestAPI"}, {"name": "host", "value": "jwdiannao"}, {"name": "thread", "value": "14124-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "test_case.qccq.test_allAPI2"}]}
|