19
19
)
20
20
21
21
22
+ # unasync anyio
22
23
def test_http_connection ():
23
24
origin = Origin (b"https" , b"example.com" , 443 )
24
25
network_backend = MockBackend (
@@ -60,6 +61,7 @@ def test_http_connection():
60
61
)
61
62
62
63
64
+ # unasync anyio
63
65
def test_concurrent_requests_not_available_on_http11_connections ():
64
66
"""
65
67
Attempting to issue a request against an already active HTTP/1.1 connection
@@ -84,6 +86,7 @@ def test_concurrent_requests_not_available_on_http11_connections():
84
86
conn .request ("GET" , "https://example.com/" )
85
87
86
88
89
+ # unasync anyio
87
90
@pytest .mark .filterwarnings ("ignore::pytest.PytestUnraisableExceptionWarning" )
88
91
def test_write_error_with_response_sent ():
89
92
"""
@@ -99,7 +102,11 @@ def __init__(self, buffer: typing.List[bytes], http2: bool = False) -> None:
99
102
super ().__init__ (buffer , http2 )
100
103
self .count = 0
101
104
102
- def write (self , buffer : bytes , timeout : typing .Optional [float ] = None ) -> None :
105
+ def write (
106
+ self ,
107
+ buffer : bytes ,
108
+ timeout : typing .Optional [float ] = None ,
109
+ ) -> None :
103
110
self .count += len (buffer )
104
111
105
112
if self .count > 1_000_000 :
@@ -136,6 +143,7 @@ def connect_tcp(
136
143
assert response .content == b"Request body exceeded 1,000,000 bytes"
137
144
138
145
146
+ # unasync anyio
139
147
@pytest .mark .filterwarnings ("ignore::pytest.PytestUnraisableExceptionWarning" )
140
148
def test_write_error_without_response_sent ():
141
149
"""
@@ -150,7 +158,11 @@ def __init__(self, buffer: typing.List[bytes], http2: bool = False) -> None:
150
158
super ().__init__ (buffer , http2 )
151
159
self .count = 0
152
160
153
- def write (self , buffer : bytes , timeout : typing .Optional [float ] = None ) -> None :
161
+ def write (
162
+ self ,
163
+ buffer : bytes ,
164
+ timeout : typing .Optional [float ] = None ,
165
+ ) -> None :
154
166
self .count += len (buffer )
155
167
156
168
if self .count > 1_000_000 :
@@ -179,6 +191,7 @@ def connect_tcp(
179
191
assert str (exc_info .value ) == "Server disconnected without sending a response."
180
192
181
193
194
+ # unasync anyio
182
195
@pytest .mark .filterwarnings ("ignore::pytest.PytestUnraisableExceptionWarning" )
183
196
def test_http2_connection ():
184
197
origin = Origin (b"https" , b"example.com" , 443 )
@@ -203,7 +216,9 @@ def test_http2_connection():
203
216
)
204
217
205
218
with HTTPConnection (
206
- origin = origin , network_backend = network_backend , http2 = True
219
+ origin = origin ,
220
+ network_backend = network_backend ,
221
+ http2 = True ,
207
222
) as conn :
208
223
response = conn .request ("GET" , "https://example.com/" )
209
224
@@ -212,13 +227,17 @@ def test_http2_connection():
212
227
assert response .extensions ["http_version" ] == b"HTTP/2"
213
228
214
229
230
+ # unasync anyio
215
231
def test_request_to_incorrect_origin ():
216
232
"""
217
233
A connection can only send requests whichever origin it is connected to.
218
234
"""
219
235
origin = Origin (b"https" , b"example.com" , 443 )
220
236
network_backend = MockBackend ([])
221
- with HTTPConnection (origin = origin , network_backend = network_backend ) as conn :
237
+ with HTTPConnection (
238
+ origin = origin ,
239
+ network_backend = network_backend ,
240
+ ) as conn :
222
241
with pytest .raises (RuntimeError ):
223
242
conn .request ("GET" , "https://other.com/" )
224
243
@@ -253,14 +272,26 @@ def connect_tcp(
253
272
return self ._NeedsRetryAsyncNetworkStream (self , stream )
254
273
255
274
class _NeedsRetryAsyncNetworkStream (NetworkStream ):
256
- def __init__ (self , backend : "NeedsRetryBackend" , stream : NetworkStream ) -> None :
275
+ def __init__ (
276
+ self ,
277
+ backend : "NeedsRetryBackend" ,
278
+ stream : NetworkStream ,
279
+ ) -> None :
257
280
self ._backend = backend
258
281
self ._stream = stream
259
282
260
- def read (self , max_bytes : int , timeout : typing .Optional [float ] = None ) -> bytes :
283
+ def read (
284
+ self ,
285
+ max_bytes : int ,
286
+ timeout : typing .Optional [float ] = None ,
287
+ ) -> bytes :
261
288
return self ._stream .read (max_bytes , timeout )
262
289
263
- def write (self , buffer : bytes , timeout : typing .Optional [float ] = None ) -> None :
290
+ def write (
291
+ self ,
292
+ buffer : bytes ,
293
+ timeout : typing .Optional [float ] = None ,
294
+ ) -> None :
264
295
self ._stream .write (buffer , timeout )
265
296
266
297
def close (self ) -> None :
@@ -283,6 +314,7 @@ def get_extra_info(self, info: str) -> typing.Any:
283
314
return self ._stream .get_extra_info (info )
284
315
285
316
317
+ # unasync anyio
286
318
def test_connection_retries ():
287
319
origin = Origin (b"https" , b"example.com" , 443 )
288
320
content = [
@@ -309,6 +341,7 @@ def test_connection_retries():
309
341
conn .request ("GET" , "https://example.com/" )
310
342
311
343
344
+ # unasync anyio
312
345
def test_connection_retries_tls ():
313
346
origin = Origin (b"https" , b"example.com" , 443 )
314
347
content = [
@@ -339,6 +372,7 @@ def test_connection_retries_tls():
339
372
conn .request ("GET" , "https://example.com/" )
340
373
341
374
375
+ # unasync anyio
342
376
def test_uds_connections ():
343
377
# We're not actually testing Unix Domain Sockets here, because we're just
344
378
# using a mock backend, but at least we're covering the UDS codepath
0 commit comments