From 42d8e18bf8d35482cdb4935866bd35304a74fc9d Mon Sep 17 00:00:00 2001 From: Ceesjan Luiten Date: Thu, 26 May 2022 12:17:22 +0200 Subject: [PATCH] Support content attribute for a Testing Response. (#968) `content` is a documented attribute of a testing response which isn't part of the parent HttpResponseBase: https://docs.djangoproject.com/en/4.0/topics/testing/tools/#testing-responses --- django-stubs/test/client.pyi | 2 ++ tests/typecheck/test/test_client.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index a4bb363..85c74ba 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -126,6 +126,7 @@ class _MonkeyPatchedWSGIResponse(_WSGIResponse): client: Client templates: List[Template] context: List[Dict[str, Any]] + content: bytes resolver_match: ResolverMatch class _MonkeyPatchedASGIResponse(_ASGIResponse): @@ -134,6 +135,7 @@ class _MonkeyPatchedASGIResponse(_ASGIResponse): client: AsyncClient templates: List[Template] context: List[Dict[str, Any]] + content: bytes resolver_match: ResolverMatch class ClientMixin: diff --git a/tests/typecheck/test/test_client.yml b/tests/typecheck/test/test_client.yml index e7ce034..0aa223e 100644 --- a/tests/typecheck/test/test_client.yml +++ b/tests/typecheck/test/test_client.yml @@ -8,6 +8,7 @@ reveal_type(response.templates) # N: Revealed type is "builtins.list[django.template.base.Template]" reveal_type(response.client) # N: Revealed type is "django.test.client.Client" reveal_type(response.context) # N: Revealed type is "builtins.list[builtins.dict[builtins.str, Any]]" + reveal_type(response.content) # N: Revealed type is "builtins.bytes" response.json() - case: async_client_methods main: | @@ -20,6 +21,7 @@ reveal_type(response.templates) # N: Revealed type is "builtins.list[django.template.base.Template]" reveal_type(response.client) # N: Revealed type is "django.test.client.AsyncClient" reveal_type(response.context) # N: Revealed type is "builtins.list[builtins.dict[builtins.str, Any]]" + reveal_type(response.content) # N: Revealed type is "builtins.bytes" response.json() - case: request_factories main: |