Skip to content

Commit 42d8e18

Browse files
authored
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
1 parent 0a13d2c commit 42d8e18

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

django-stubs/test/client.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class _MonkeyPatchedWSGIResponse(_WSGIResponse):
126126
client: Client
127127
templates: List[Template]
128128
context: List[Dict[str, Any]]
129+
content: bytes
129130
resolver_match: ResolverMatch
130131

131132
class _MonkeyPatchedASGIResponse(_ASGIResponse):
@@ -134,6 +135,7 @@ class _MonkeyPatchedASGIResponse(_ASGIResponse):
134135
client: AsyncClient
135136
templates: List[Template]
136137
context: List[Dict[str, Any]]
138+
content: bytes
137139
resolver_match: ResolverMatch
138140

139141
class ClientMixin:

tests/typecheck/test/test_client.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
reveal_type(response.templates) # N: Revealed type is "builtins.list[django.template.base.Template]"
99
reveal_type(response.client) # N: Revealed type is "django.test.client.Client"
1010
reveal_type(response.context) # N: Revealed type is "builtins.list[builtins.dict[builtins.str, Any]]"
11+
reveal_type(response.content) # N: Revealed type is "builtins.bytes"
1112
response.json()
1213
- case: async_client_methods
1314
main: |
@@ -20,6 +21,7 @@
2021
reveal_type(response.templates) # N: Revealed type is "builtins.list[django.template.base.Template]"
2122
reveal_type(response.client) # N: Revealed type is "django.test.client.AsyncClient"
2223
reveal_type(response.context) # N: Revealed type is "builtins.list[builtins.dict[builtins.str, Any]]"
24+
reveal_type(response.content) # N: Revealed type is "builtins.bytes"
2325
response.json()
2426
- case: request_factories
2527
main: |

0 commit comments

Comments
 (0)