问题
pytest主函数运行正常 但是命令行运行报错,只有我的电脑会这样,别人的电脑都可以正常运行,一开始以为是读不到路径的问题,在调试之后,感觉不是路径的问题。
而且主函数运行正常,终端命令行运行报错(只有我的电脑会这样)
在获取token的时候 报错requests.exceptions.SSLError
报错信息
KeyError: 'data'
self = <testcase_interface.test_litemall.Test object at 0x000001B18CBD6040>
par = {'request': {'data': {'password': 'wyc123', 'username': 'wyc'}, 'headers': {'content-type': 'application/json;charset=...d': 'post', 'url': 'https://litemall.hogwarts.ceshiren.com/wx/auth/login'}, 'title': '调用登录接口获取token', 'validate': None}
@pytest.mark.parametrize("par", YamlUtil().read_test_yaml("/testcase_interface/get_login_token.yaml"))
def test_get_login_token(self, par):
url = par["request"]["url"]
method = par["request"]["method"]
data = par["request"]["data"]
headers = par["request"]["headers"]
res = RequestUtil().all_send_request(method=method, url=url, json=data, headers=headers)
result = res.json()
> result_data = (result['data'])
E KeyError: 'data'
testcase_interface\test_litemall.py:21: KeyError
环境
编辑器:pycharm
解释器:python3.9 (conda)