如何修复“ AssertionError:403!= 401”

时间:2019-05-20 14:41:57

标签: python django unit-testing assertion

我正在用Django编写针对用户授权的测试。我收到AssertionError:403!= 401

def test_authorization_is_enforced(self):
        """Test that the api has user authorization."""
        new_client = APIClient()
        res = new_client.get('/bucketlists/', kwargs={'pk': 3}, format="json")
        self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)


 self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)

AssertionError:403!= 401

0 个答案:

没有答案