[英]FastAPI POST Pydantic method unit testing redirecting status_code 307 instead of 200
[英]Python requests.post() method command returns 200 status_code attribute instead of 500
即使 AWS Lambda 服务器发回 500,我也收到 200 的 status_code:
[
这是返回响应的代码(注意:我尝试了 500 和 '500',两者效果相同):
return {
'statusCode': '500',
'headers': {
'Content-Type': 'application/json',
},
'body': 'Authentication failed!'
}
这是在烧瓶中启动响应的代码:
response = requests.post(URLS.sign_in.get("endpoint"),
json={"user": form.email.data, "pass": form.password.data})
statusCode 正确为 500,因为输入不正确,但这不应该反映在 status_code 属性中吗? 知道为什么会发生这种情况吗? 非常感谢大家。
您收到 status_code 200(成功 HTTP 请求的标准响应。)因为服务器正常,服务器已到达并且处理也已执行。
唯一的问题是与您正在测试的用户不匹配,因此这不会导致 status_code 500(内部服务器错误)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.