APIClient methods Response return
DRF defines APITestCase this way:
class APITestCase(testcases.TestCase):
client_class = APIClient
So typing doesn't infer the new client type, and uses instead Django Client, which has the correct return type for its HTTP methods
(method) get: (path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any) -> HttpResponse
But when I subclass APITestCase and want to customize it and type it with:
class TokenAuthAPITestCase(APITestCase):
client: APIClient
I have this return type for APIClient.post:
(method) get: (path: Unknown, data: Unknown = None, follow: Unknown = False, **extra: Unknown) -> Unknown | WSGIRequest
Shouldn't it return a rest_framework.response.Response instance?
Let me know if I'm right, and in this case if I can help with that
I'm getting the same error in my tests - it seems that self.client is typed as django.test.client.Client in my tests, instead of the expected APIClient, even though my test class subclasses APITestCase.
Sounds like it was fixed :)