6
6
import httpx
7
7
8
8
9
- @pytest .mark .usefixtures ( "async_environment" )
9
+ @pytest .mark .anyio
10
10
async def test_get (server ):
11
11
url = server .url
12
12
async with httpx .AsyncClient (http2 = True ) as client :
@@ -27,14 +27,14 @@ async def test_get(server):
27
27
pytest .param ("http://" , id = "no-host" ),
28
28
],
29
29
)
30
- @pytest .mark .usefixtures ( "async_environment" )
30
+ @pytest .mark .anyio
31
31
async def test_get_invalid_url (server , url ):
32
32
async with httpx .AsyncClient () as client :
33
33
with pytest .raises ((httpx .UnsupportedProtocol , httpx .LocalProtocolError )):
34
34
await client .get (url )
35
35
36
36
37
- @pytest .mark .usefixtures ( "async_environment" )
37
+ @pytest .mark .anyio
38
38
async def test_build_request (server ):
39
39
url = server .url .copy_with (path = "/echo_headers" )
40
40
headers = {"Custom-header" : "value" }
@@ -49,23 +49,23 @@ async def test_build_request(server):
49
49
assert response .json ()["Custom-header" ] == "value"
50
50
51
51
52
- @pytest .mark .usefixtures ( "async_environment" )
52
+ @pytest .mark .anyio
53
53
async def test_post (server ):
54
54
url = server .url
55
55
async with httpx .AsyncClient () as client :
56
56
response = await client .post (url , content = b"Hello, world!" )
57
57
assert response .status_code == 200
58
58
59
59
60
- @pytest .mark .usefixtures ( "async_environment" )
60
+ @pytest .mark .anyio
61
61
async def test_post_json (server ):
62
62
url = server .url
63
63
async with httpx .AsyncClient () as client :
64
64
response = await client .post (url , json = {"text" : "Hello, world!" })
65
65
assert response .status_code == 200
66
66
67
67
68
- @pytest .mark .usefixtures ( "async_environment" )
68
+ @pytest .mark .anyio
69
69
async def test_stream_response (server ):
70
70
async with httpx .AsyncClient () as client :
71
71
async with client .stream ("GET" , server .url ) as response :
@@ -76,7 +76,7 @@ async def test_stream_response(server):
76
76
assert response .content == b"Hello, world!"
77
77
78
78
79
- @pytest .mark .usefixtures ( "async_environment" )
79
+ @pytest .mark .anyio
80
80
async def test_access_content_stream_response (server ):
81
81
async with httpx .AsyncClient () as client :
82
82
async with client .stream ("GET" , server .url ) as response :
@@ -87,7 +87,7 @@ async def test_access_content_stream_response(server):
87
87
response .content
88
88
89
89
90
- @pytest .mark .usefixtures ( "async_environment" )
90
+ @pytest .mark .anyio
91
91
async def test_stream_request (server ):
92
92
async def hello_world () -> typing .AsyncIterator [bytes ]:
93
93
yield b"Hello, "
@@ -98,7 +98,7 @@ async def hello_world() -> typing.AsyncIterator[bytes]:
98
98
assert response .status_code == 200
99
99
100
100
101
- @pytest .mark .usefixtures ( "async_environment" )
101
+ @pytest .mark .anyio
102
102
async def test_cannot_stream_sync_request (server ):
103
103
def hello_world () -> typing .Iterator [bytes ]: # pragma: no cover
104
104
yield b"Hello, "
@@ -109,7 +109,7 @@ def hello_world() -> typing.Iterator[bytes]: # pragma: no cover
109
109
await client .post (server .url , content = hello_world ())
110
110
111
111
112
- @pytest .mark .usefixtures ( "async_environment" )
112
+ @pytest .mark .anyio
113
113
async def test_raise_for_status (server ):
114
114
async with httpx .AsyncClient () as client :
115
115
for status_code in (200 , 400 , 404 , 500 , 505 ):
@@ -125,45 +125,45 @@ async def test_raise_for_status(server):
125
125
assert response .raise_for_status () is None # type: ignore
126
126
127
127
128
- @pytest .mark .usefixtures ( "async_environment" )
128
+ @pytest .mark .anyio
129
129
async def test_options (server ):
130
130
async with httpx .AsyncClient () as client :
131
131
response = await client .options (server .url )
132
132
assert response .status_code == 200
133
133
assert response .text == "Hello, world!"
134
134
135
135
136
- @pytest .mark .usefixtures ( "async_environment" )
136
+ @pytest .mark .anyio
137
137
async def test_head (server ):
138
138
async with httpx .AsyncClient () as client :
139
139
response = await client .head (server .url )
140
140
assert response .status_code == 200
141
141
assert response .text == ""
142
142
143
143
144
- @pytest .mark .usefixtures ( "async_environment" )
144
+ @pytest .mark .anyio
145
145
async def test_put (server ):
146
146
async with httpx .AsyncClient () as client :
147
147
response = await client .put (server .url , content = b"Hello, world!" )
148
148
assert response .status_code == 200
149
149
150
150
151
- @pytest .mark .usefixtures ( "async_environment" )
151
+ @pytest .mark .anyio
152
152
async def test_patch (server ):
153
153
async with httpx .AsyncClient () as client :
154
154
response = await client .patch (server .url , content = b"Hello, world!" )
155
155
assert response .status_code == 200
156
156
157
157
158
- @pytest .mark .usefixtures ( "async_environment" )
158
+ @pytest .mark .anyio
159
159
async def test_delete (server ):
160
160
async with httpx .AsyncClient () as client :
161
161
response = await client .delete (server .url )
162
162
assert response .status_code == 200
163
163
assert response .text == "Hello, world!"
164
164
165
165
166
- @pytest .mark .usefixtures ( "async_environment" )
166
+ @pytest .mark .anyio
167
167
async def test_100_continue (server ):
168
168
headers = {"Expect" : "100-continue" }
169
169
content = b"Echo request body"
@@ -177,7 +177,7 @@ async def test_100_continue(server):
177
177
assert response .content == content
178
178
179
179
180
- @pytest .mark .usefixtures ( "async_environment" )
180
+ @pytest .mark .anyio
181
181
async def test_context_managed_transport ():
182
182
class Transport (httpx .AsyncBaseTransport ):
183
183
def __init__ (self ) -> None :
@@ -209,7 +209,7 @@ async def __aexit__(self, *args):
209
209
]
210
210
211
211
212
- @pytest .mark .usefixtures ( "async_environment" )
212
+ @pytest .mark .anyio
213
213
async def test_context_managed_transport_and_mount ():
214
214
class Transport (httpx .AsyncBaseTransport ):
215
215
def __init__ (self , name : str ):
@@ -254,7 +254,7 @@ def hello_world(request):
254
254
return httpx .Response (200 , text = "Hello, world!" )
255
255
256
256
257
- @pytest .mark .usefixtures ( "async_environment" )
257
+ @pytest .mark .anyio
258
258
async def test_client_closed_state_using_implicit_open ():
259
259
client = httpx .AsyncClient (transport = httpx .MockTransport (hello_world ))
260
260
@@ -275,7 +275,7 @@ async def test_client_closed_state_using_implicit_open():
275
275
pass # pragma: no cover
276
276
277
277
278
- @pytest .mark .usefixtures ( "async_environment" )
278
+ @pytest .mark .anyio
279
279
async def test_client_closed_state_using_with_block ():
280
280
async with httpx .AsyncClient (transport = httpx .MockTransport (hello_world )) as client :
281
281
assert not client .is_closed
@@ -296,7 +296,7 @@ def mounted(request: httpx.Request) -> httpx.Response:
296
296
return httpx .Response (200 , json = data )
297
297
298
298
299
- @pytest .mark .usefixtures ( "async_environment" )
299
+ @pytest .mark .anyio
300
300
async def test_mounted_transport ():
301
301
transport = httpx .MockTransport (unmounted )
302
302
mounts = {"custom://" : httpx .MockTransport (mounted )}
@@ -311,7 +311,7 @@ async def test_mounted_transport():
311
311
assert response .json () == {"app" : "mounted" }
312
312
313
313
314
- @pytest .mark .usefixtures ( "async_environment" )
314
+ @pytest .mark .anyio
315
315
async def test_async_mock_transport ():
316
316
async def hello_world (request ):
317
317
return httpx .Response (200 , text = "Hello, world!" )
@@ -324,7 +324,7 @@ async def hello_world(request):
324
324
assert response .text == "Hello, world!"
325
325
326
326
327
- @pytest .mark .usefixtures ( "async_environment" )
327
+ @pytest .mark .anyio
328
328
async def test_cancellation_during_stream ():
329
329
"""
330
330
If any BaseException is raised during streaming the response, then the
@@ -364,7 +364,7 @@ async def aclose(self) -> None:
364
364
assert stream_was_closed
365
365
366
366
367
- @pytest .mark .usefixtures ( "async_environment" )
367
+ @pytest .mark .anyio
368
368
async def test_server_extensions (server ):
369
369
url = server .url
370
370
async with httpx .AsyncClient (http2 = True ) as client :
0 commit comments