@@ -27,7 +27,7 @@ def get_header_value(headers, key, default=None):
2727 return default
2828
2929
30- class MockDispatch (httpcore .AsyncHTTPTransport ):
30+ class MockTransport (httpcore .AsyncHTTPTransport ):
3131 def __init__ (self , auth_header : bytes = b"" , status_code : int = 200 ) -> None :
3232 self .auth_header = auth_header
3333 self .status_code = status_code
@@ -50,7 +50,7 @@ async def request(
5050 return b"HTTP/1.1" , self .status_code , b"" , response_headers , response_stream
5151
5252
53- class MockDigestAuthDispatch (httpcore .AsyncHTTPTransport ):
53+ class MockDigestAuthTransport (httpcore .AsyncHTTPTransport ):
5454 def __init__ (
5555 self ,
5656 algorithm : str = "SHA-256" ,
@@ -119,7 +119,7 @@ async def test_basic_auth() -> None:
119119 url = "https://example.org/"
120120 auth = ("tomchristie" , "password123" )
121121
122- client = AsyncClient (dispatch = MockDispatch ())
122+ client = AsyncClient (transport = MockTransport ())
123123 response = await client .get (url , auth = auth )
124124
125125 assert response .status_code == 200
@@ -130,7 +130,7 @@ async def test_basic_auth() -> None:
130130async def test_basic_auth_in_url () -> None :
131131 url = "https://tomchristie:[email protected] /" 132132
133- client = AsyncClient (dispatch = MockDispatch ())
133+ client = AsyncClient (transport = MockTransport ())
134134 response = await client .get (url )
135135
136136 assert response .status_code == 200
@@ -142,7 +142,7 @@ async def test_basic_auth_on_session() -> None:
142142 url = "https://example.org/"
143143 auth = ("tomchristie" , "password123" )
144144
145- client = AsyncClient (dispatch = MockDispatch (), auth = auth )
145+ client = AsyncClient (transport = MockTransport (), auth = auth )
146146 response = await client .get (url )
147147
148148 assert response .status_code == 200
@@ -157,7 +157,7 @@ def auth(request: Request) -> Request:
157157 request .headers ["Authorization" ] = "Token 123"
158158 return request
159159
160- client = AsyncClient (dispatch = MockDispatch ())
160+ client = AsyncClient (transport = MockTransport ())
161161 response = await client .get (url , auth = auth )
162162
163163 assert response .status_code == 200
@@ -169,7 +169,7 @@ async def test_netrc_auth() -> None:
169169 os .environ ["NETRC" ] = "tests/.netrc"
170170 url = "http://netrcexample.org"
171171
172- client = AsyncClient (dispatch = MockDispatch ())
172+ client = AsyncClient (transport = MockTransport ())
173173 response = await client .get (url )
174174
175175 assert response .status_code == 200
@@ -183,7 +183,7 @@ async def test_auth_header_has_priority_over_netrc() -> None:
183183 os .environ ["NETRC" ] = "tests/.netrc"
184184 url = "http://netrcexample.org"
185185
186- client = AsyncClient (dispatch = MockDispatch ())
186+ client = AsyncClient (transport = MockTransport ())
187187 response = await client .get (url , headers = {"Authorization" : "Override" })
188188
189189 assert response .status_code == 200
@@ -195,13 +195,13 @@ async def test_trust_env_auth() -> None:
195195 os .environ ["NETRC" ] = "tests/.netrc"
196196 url = "http://netrcexample.org"
197197
198- client = AsyncClient (dispatch = MockDispatch (), trust_env = False )
198+ client = AsyncClient (transport = MockTransport (), trust_env = False )
199199 response = await client .get (url )
200200
201201 assert response .status_code == 200
202202 assert response .json () == {"auth" : None }
203203
204- client = AsyncClient (dispatch = MockDispatch (), trust_env = True )
204+ client = AsyncClient (transport = MockTransport (), trust_env = True )
205205 response = await client .get (url )
206206
207207 assert response .status_code == 200
@@ -222,7 +222,7 @@ async def test_auth_hidden_header() -> None:
222222 url = "https://example.org/"
223223 auth = ("example-username" , "example-password" )
224224
225- client = AsyncClient (dispatch = MockDispatch ())
225+ client = AsyncClient (transport = MockTransport ())
226226 response = await client .get (url , auth = auth )
227227
228228 assert "'authorization': '[secure]'" in str (response .request .headers )
@@ -232,7 +232,7 @@ async def test_auth_hidden_header() -> None:
232232async def test_auth_invalid_type () -> None :
233233 url = "https://example.org/"
234234 client = AsyncClient (
235- dispatch = MockDispatch (), auth = "not a tuple, not a callable" , # type: ignore
235+ transport = MockTransport (), auth = "not a tuple, not a callable" , # type: ignore
236236 )
237237 with pytest .raises (TypeError ):
238238 await client .get (url )
@@ -243,7 +243,7 @@ async def test_digest_auth_returns_no_auth_if_no_digest_header_in_response() ->
243243 url = "https://example.org/"
244244 auth = DigestAuth (username = "tomchristie" , password = "password123" )
245245
246- client = AsyncClient (dispatch = MockDispatch ())
246+ client = AsyncClient (transport = MockTransport ())
247247 response = await client .get (url , auth = auth )
248248
249249 assert response .status_code == 200
@@ -258,7 +258,7 @@ async def test_digest_auth_200_response_including_digest_auth_header() -> None:
258258 auth_header = b'Digest realm="[email protected] ",qop="auth",nonce="abc",opaque="xyz"' 259259
260260 client = AsyncClient (
261- dispatch = MockDispatch (auth_header = auth_header , status_code = 200 )
261+ transport = MockTransport (auth_header = auth_header , status_code = 200 )
262262 )
263263 response = await client .get (url , auth = auth )
264264
@@ -272,7 +272,7 @@ async def test_digest_auth_401_response_without_digest_auth_header() -> None:
272272 url = "https://example.org/"
273273 auth = DigestAuth (username = "tomchristie" , password = "password123" )
274274
275- client = AsyncClient (dispatch = MockDispatch (auth_header = b"" , status_code = 401 ))
275+ client = AsyncClient (transport = MockTransport (auth_header = b"" , status_code = 401 ))
276276 response = await client .get (url , auth = auth )
277277
278278 assert response .status_code == 401
@@ -300,7 +300,7 @@ async def test_digest_auth(
300300 url = "https://example.org/"
301301 auth = DigestAuth (username = "tomchristie" , password = "password123" )
302302
303- client = AsyncClient (dispatch = MockDigestAuthDispatch (algorithm = algorithm ))
303+ client = AsyncClient (transport = MockDigestAuthTransport (algorithm = algorithm ))
304304 response = await client .get (url , auth = auth )
305305
306306 assert response .status_code == 200
@@ -330,7 +330,7 @@ async def test_digest_auth_no_specified_qop() -> None:
330330 url = "https://example.org/"
331331 auth = DigestAuth (username = "tomchristie" , password = "password123" )
332332
333- client = AsyncClient (dispatch = MockDigestAuthDispatch (qop = "" ))
333+ client = AsyncClient (transport = MockDigestAuthTransport (qop = "" ))
334334 response = await client .get (url , auth = auth )
335335
336336 assert response .status_code == 200
@@ -361,7 +361,7 @@ async def test_digest_auth_qop_including_spaces_and_auth_returns_auth(qop: str)
361361 url = "https://example.org/"
362362 auth = DigestAuth (username = "tomchristie" , password = "password123" )
363363
364- client = AsyncClient (dispatch = MockDigestAuthDispatch (qop = qop ))
364+ client = AsyncClient (transport = MockDigestAuthTransport (qop = qop ))
365365 response = await client .get (url , auth = auth )
366366
367367 assert response .status_code == 200
@@ -372,7 +372,7 @@ async def test_digest_auth_qop_including_spaces_and_auth_returns_auth(qop: str)
372372async def test_digest_auth_qop_auth_int_not_implemented () -> None :
373373 url = "https://example.org/"
374374 auth = DigestAuth (username = "tomchristie" , password = "password123" )
375- client = AsyncClient (dispatch = MockDigestAuthDispatch (qop = "auth-int" ))
375+ client = AsyncClient (transport = MockDigestAuthTransport (qop = "auth-int" ))
376376
377377 with pytest .raises (NotImplementedError ):
378378 await client .get (url , auth = auth )
@@ -382,7 +382,7 @@ async def test_digest_auth_qop_auth_int_not_implemented() -> None:
382382async def test_digest_auth_qop_must_be_auth_or_auth_int () -> None :
383383 url = "https://example.org/"
384384 auth = DigestAuth (username = "tomchristie" , password = "password123" )
385- client = AsyncClient (dispatch = MockDigestAuthDispatch (qop = "not-auth" ))
385+ client = AsyncClient (transport = MockDigestAuthTransport (qop = "not-auth" ))
386386
387387 with pytest .raises (ProtocolError ):
388388 await client .get (url , auth = auth )
@@ -393,7 +393,9 @@ async def test_digest_auth_incorrect_credentials() -> None:
393393 url = "https://example.org/"
394394 auth = DigestAuth (username = "tomchristie" , password = "password123" )
395395
396- client = AsyncClient (dispatch = MockDigestAuthDispatch (send_response_after_attempt = 2 ))
396+ client = AsyncClient (
397+ transport = MockDigestAuthTransport (send_response_after_attempt = 2 )
398+ )
397399 response = await client .get (url , auth = auth )
398400
399401 assert response .status_code == 401
@@ -417,7 +419,7 @@ async def test_digest_auth_raises_protocol_error_on_malformed_header(
417419 url = "https://example.org/"
418420 auth = DigestAuth (username = "tomchristie" , password = "password123" )
419421 client = AsyncClient (
420- dispatch = MockDispatch (auth_header = auth_header , status_code = 401 )
422+ transport = MockTransport (auth_header = auth_header , status_code = 401 )
421423 )
422424
423425 with pytest .raises (ProtocolError ):
@@ -460,7 +462,7 @@ def auth_flow(
460462
461463 url = "https://example.org/"
462464 auth = RepeatAuth (repeat = 2 )
463- client = AsyncClient (dispatch = MockDispatch (auth_header = b"abc" ))
465+ client = AsyncClient (transport = MockTransport (auth_header = b"abc" ))
464466
465467 response = await client .get (url , auth = auth )
466468 assert response .status_code == 200
@@ -481,7 +483,7 @@ def auth_flow(
481483async def test_digest_auth_unavailable_streaming_body ():
482484 url = "https://example.org/"
483485 auth = DigestAuth (username = "tomchristie" , password = "password123" )
484- client = AsyncClient (dispatch = MockDispatch ())
486+ client = AsyncClient (transport = MockTransport ())
485487
486488 async def streaming_body ():
487489 yield b"Example request body" # pragma: nocover
@@ -520,7 +522,7 @@ def auth_flow(
520522
521523 url = "https://example.org/"
522524 auth = ResponseBodyAuth ("xyz" )
523- client = AsyncClient (dispatch = MockDispatch ())
525+ client = AsyncClient (transport = MockTransport ())
524526
525527 response = await client .get (url , auth = auth )
526528 assert response .status_code == 200
0 commit comments