即使状态代码正确,Pytest AssertionError

Pytest AssertionError even if status code is correct

为什么我一直收到 AssertionError 而实际返回 400,因为第 14 行已设置?

14   assert status_code == 400
15   AssertionError: assert (400, 'Please fulfill all parts!') == 400

谢谢!

您试图断言 int 等于 tuple

指定status_code的索引即可解决

即:assert status_code[0] == 400