Skip to content

Commit c7dff6f

Browse files
committed
Add new headers parameter to test classes
1 parent af3ad5a commit c7dff6f

File tree

1 file changed

+154
-20
lines changed

1 file changed

+154
-20
lines changed

django-stubs/test/client.pyi

+154-20
Original file line numberDiff line numberDiff line change
@@ -72,26 +72,95 @@ class _RequestFactory(Generic[_T]):
7272
errors: BytesIO
7373
def __init__(self, *, json_encoder: type[JSONEncoder] = ..., **defaults: Any) -> None: ...
7474
def request(self, **request: Any) -> _T: ...
75-
def get(self, path: str, data: _GetDataType = ..., secure: bool = ..., **extra: Any) -> _T: ...
76-
def post(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ...
77-
def head(self, path: str, data: Any = ..., secure: bool = ..., **extra: Any) -> _T: ...
78-
def trace(self, path: str, secure: bool = ..., **extra: Any) -> _T: ...
75+
def get(
76+
self,
77+
path: str,
78+
data: _GetDataType = ...,
79+
secure: bool = ...,
80+
*,
81+
headers: dict[str, Any] | None = ...,
82+
**extra: Any
83+
) -> _T: ...
84+
def post(
85+
self,
86+
path: str,
87+
data: Any = ...,
88+
content_type: str = ...,
89+
secure: bool = ...,
90+
*,
91+
headers: dict[str, Any] | None = ...,
92+
**extra: Any
93+
) -> _T: ...
94+
def head(
95+
self, path: str, data: Any = ..., secure: bool = ..., *, headers: dict[str, Any] | None = ..., **extra: Any
96+
) -> _T: ...
97+
def trace(self, path: str, secure: bool = ..., *, headers: dict[str, Any] | None = ..., **extra: Any) -> _T: ...
7998
def options(
80-
self, path: str, data: dict[str, str] | str = ..., content_type: str = ..., secure: bool = ..., **extra: Any
99+
self,
100+
path: str,
101+
data: dict[str, str] | str = ...,
102+
content_type: str = ...,
103+
secure: bool = ...,
104+
*,
105+
headers: dict[str, Any] | None = ...,
106+
**extra: Any
107+
) -> _T: ...
108+
def put(
109+
self,
110+
path: str,
111+
data: Any = ...,
112+
content_type: str = ...,
113+
secure: bool = ...,
114+
*,
115+
headers: dict[str, Any] | None = ...,
116+
**extra: Any
117+
) -> _T: ...
118+
def patch(
119+
self,
120+
path: str,
121+
data: Any = ...,
122+
content_type: str = ...,
123+
secure: bool = ...,
124+
*,
125+
headers: dict[str, Any] | None = ...,
126+
**extra: Any
127+
) -> _T: ...
128+
def delete(
129+
self,
130+
path: str,
131+
data: Any = ...,
132+
content_type: str = ...,
133+
secure: bool = ...,
134+
*,
135+
headers: dict[str, Any] | None = ...,
136+
**extra: Any
81137
) -> _T: ...
82-
def put(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ...
83-
def patch(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ...
84-
def delete(self, path: str, data: Any = ..., content_type: str = ..., secure: bool = ..., **extra: Any) -> _T: ...
85138
def generic(
86-
self, method: str, path: str, data: Any = ..., content_type: str | None = ..., secure: bool = ..., **extra: Any
139+
self,
140+
method: str,
141+
path: str,
142+
data: Any = ...,
143+
content_type: str | None = ...,
144+
secure: bool = ...,
145+
*,
146+
headers: dict[str, Any] | None = ...,
147+
**extra: Any
87148
) -> _T: ...
88149

89150
class RequestFactory(_RequestFactory[WSGIRequest]): ...
90151

91152
class _AsyncRequestFactory(_RequestFactory[_T]):
92153
def request(self, **request: Any) -> _T: ...
93154
def generic(
94-
self, method: str, path: str, data: Any = ..., content_type: str | None = ..., secure: bool = ..., **extra: Any
155+
self,
156+
method: str,
157+
path: str,
158+
data: Any = ...,
159+
content_type: str | None = ...,
160+
secure: bool = ...,
161+
*,
162+
headers: dict[str, Any] | None = ...,
163+
**extra: Any
95164
) -> _T: ...
96165

97166
class AsyncRequestFactory(_AsyncRequestFactory[ASGIRequest]): ...
@@ -130,39 +199,104 @@ class Client(ClientMixin, _RequestFactory[_MonkeyPatchedWSGIResponse]):
130199
handler: ClientHandler
131200
raise_request_exception: bool
132201
exc_info: tuple[type[BaseException], BaseException, TracebackType] | None
202+
extra: Any
203+
headers: dict[str, Any]
133204
def __init__(
134-
self, enforce_csrf_checks: bool = ..., raise_request_exception: bool = ..., **defaults: Any
205+
self,
206+
enforce_csrf_checks: bool = ...,
207+
raise_request_exception: bool = ...,
208+
*,
209+
headers: dict[str, Any] | None = ...,
210+
**defaults: Any
135211
) -> None: ...
136-
# Silence type warnings, since this class overrides arguments and return types in an unsafe manner.
137212
def request(self, **request: Any) -> _MonkeyPatchedWSGIResponse: ...
138213
def get( # type: ignore
139-
self, path: str, data: _GetDataType = ..., follow: bool = ..., secure: bool = ..., **extra: Any
214+
self,
215+
path: str,
216+
data: _GetDataType = ...,
217+
follow: bool = ...,
218+
secure: bool = ...,
219+
*,
220+
headers: dict[str, Any] | None,
221+
**extra: Any
140222
) -> _MonkeyPatchedWSGIResponse: ...
141223
def post( # type: ignore
142-
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
224+
self,
225+
path: str,
226+
data: Any = ...,
227+
content_type: str = ...,
228+
follow: bool = ...,
229+
secure: bool = ...,
230+
*,
231+
headers: dict[str, Any] | None,
232+
**extra: Any
143233
) -> _MonkeyPatchedWSGIResponse: ...
144234
def head( # type: ignore
145-
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
235+
self,
236+
path: str,
237+
data: Any = ...,
238+
follow: bool = ...,
239+
secure: bool = ...,
240+
*,
241+
headers: dict[str, Any] | None,
242+
**extra: Any
146243
) -> _MonkeyPatchedWSGIResponse: ...
147244
def trace( # type: ignore
148-
self, path: str, data: Any = ..., follow: bool = ..., secure: bool = ..., **extra: Any
245+
self,
246+
path: str,
247+
data: Any = ...,
248+
follow: bool = ...,
249+
secure: bool = ...,
250+
*,
251+
headers: dict[str, Any] | None,
252+
**extra: Any
149253
) -> _MonkeyPatchedWSGIResponse: ...
150254
def put( # type: ignore
151-
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
255+
self,
256+
path: str,
257+
data: Any = ...,
258+
content_type: str = ...,
259+
follow: bool = ...,
260+
secure: bool = ...,
261+
*,
262+
headers: dict[str, Any] | None,
263+
**extra: Any
152264
) -> _MonkeyPatchedWSGIResponse: ...
153265
def patch( # type: ignore
154-
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
266+
self,
267+
path: str,
268+
data: Any = ...,
269+
content_type: str = ...,
270+
follow: bool = ...,
271+
secure: bool = ...,
272+
*,
273+
headers: dict[str, Any] | None,
274+
**extra: Any
155275
) -> _MonkeyPatchedWSGIResponse: ...
156276
def delete( # type: ignore
157-
self, path: str, data: Any = ..., content_type: str = ..., follow: bool = ..., secure: bool = ..., **extra: Any
277+
self,
278+
path: str,
279+
data: Any = ...,
280+
content_type: str = ...,
281+
follow: bool = ...,
282+
secure: bool = ...,
283+
*,
284+
headers: dict[str, Any] | None,
285+
**extra: Any
158286
) -> _MonkeyPatchedWSGIResponse: ...
159287

160288
class AsyncClient(ClientMixin, _AsyncRequestFactory[Awaitable[_MonkeyPatchedASGIResponse]]):
161289
handler: AsyncClientHandler
162290
raise_request_exception: bool
163291
exc_info: Any
164292
extra: Any
293+
headers: dict[str, Any]
165294
def __init__(
166-
self, enforce_csrf_checks: bool = ..., raise_request_exception: bool = ..., **defaults: Any
295+
self,
296+
enforce_csrf_checks: bool = ...,
297+
raise_request_exception: bool = ...,
298+
*,
299+
headers: dict[str, Any] | None = ...,
300+
**defaults: Any
167301
) -> None: ...
168302
async def request(self, **request: Any) -> _MonkeyPatchedASGIResponse: ...

0 commit comments

Comments
 (0)