Skip to content

Commit c23bb69

Browse files
committed
Drop upper version bound of pytest-aiohttp
Use fixture `aiohttp_client` instead of `test_client`. All the tests back to Python 3.5 complained that `test_client` was deprecated.
1 parent 9cee62e commit c23bb69

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

tests/ext/aiohttp/test_middleware.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,15 @@ def recorder(loop):
120120
patcher.stop()
121121

122122

123-
async def test_ok(test_client, loop, recorder):
123+
async def test_ok(aiohttp_client, loop, recorder):
124124
"""
125125
Test a normal response
126126
127-
:param test_client: AioHttp test client fixture
127+
:param aiohttp_client: AioHttp test client fixture
128128
:param loop: Eventloop fixture
129129
:param recorder: X-Ray recorder fixture
130130
"""
131-
client = await test_client(ServerTest.app(loop=loop))
131+
client = await aiohttp_client(ServerTest.app(loop=loop))
132132

133133
resp = await client.get('/')
134134
assert resp.status == 200
@@ -144,15 +144,15 @@ async def test_ok(test_client, loop, recorder):
144144
assert response['status'] == 200
145145

146146

147-
async def test_ok_x_forwarded_for(test_client, loop, recorder):
147+
async def test_ok_x_forwarded_for(aiohttp_client, loop, recorder):
148148
"""
149149
Test a normal response with x_forwarded_for headers
150150
151-
:param test_client: AioHttp test client fixture
151+
:param aiohttp_client: AioHttp test client fixture
152152
:param loop: Eventloop fixture
153153
:param recorder: X-Ray recorder fixture
154154
"""
155-
client = await test_client(ServerTest.app(loop=loop))
155+
client = await aiohttp_client(ServerTest.app(loop=loop))
156156

157157
resp = await client.get('/', headers={'X-Forwarded-For': 'foo'})
158158
assert resp.status == 200
@@ -162,15 +162,15 @@ async def test_ok_x_forwarded_for(test_client, loop, recorder):
162162
assert segment.http['request']['x_forwarded_for']
163163

164164

165-
async def test_ok_content_length(test_client, loop, recorder):
165+
async def test_ok_content_length(aiohttp_client, loop, recorder):
166166
"""
167167
Test a normal response with content length as response header
168168
169-
:param test_client: AioHttp test client fixture
169+
:param aiohttp_client: AioHttp test client fixture
170170
:param loop: Eventloop fixture
171171
:param recorder: X-Ray recorder fixture
172172
"""
173-
client = await test_client(ServerTest.app(loop=loop))
173+
client = await aiohttp_client(ServerTest.app(loop=loop))
174174

175175
resp = await client.get('/?content_length=100')
176176
assert resp.status == 200
@@ -179,15 +179,15 @@ async def test_ok_content_length(test_client, loop, recorder):
179179
assert segment.http['response']['content_length'] == 100
180180

181181

182-
async def test_error(test_client, loop, recorder):
182+
async def test_error(aiohttp_client, loop, recorder):
183183
"""
184184
Test a 4XX response
185185
186-
:param test_client: AioHttp test client fixture
186+
:param aiohttp_client: AioHttp test client fixture
187187
:param loop: Eventloop fixture
188188
:param recorder: X-Ray recorder fixture
189189
"""
190-
client = await test_client(ServerTest.app(loop=loop))
190+
client = await aiohttp_client(ServerTest.app(loop=loop))
191191

192192
resp = await client.get('/error')
193193
assert resp.status == 404
@@ -204,15 +204,15 @@ async def test_error(test_client, loop, recorder):
204204
assert response['status'] == 404
205205

206206

207-
async def test_exception(test_client, loop, recorder):
207+
async def test_exception(aiohttp_client, loop, recorder):
208208
"""
209209
Test handling an exception
210210
211-
:param test_client: AioHttp test client fixture
211+
:param aiohttp_client: AioHttp test client fixture
212212
:param loop: Eventloop fixture
213213
:param recorder: X-Ray recorder fixture
214214
"""
215-
client = await test_client(ServerTest.app(loop=loop))
215+
client = await aiohttp_client(ServerTest.app(loop=loop))
216216

217217
with pytest.raises(Exception):
218218
await client.get('/exception')
@@ -231,15 +231,15 @@ async def test_exception(test_client, loop, recorder):
231231
assert exception.type == 'CancelledError'
232232

233233

234-
async def test_unhauthorized(test_client, loop, recorder):
234+
async def test_unhauthorized(aiohttp_client, loop, recorder):
235235
"""
236236
Test a 401 response
237237
238-
:param test_client: AioHttp test client fixture
238+
:param aiohttp_client: AioHttp test client fixture
239239
:param loop: Eventloop fixture
240240
:param recorder: X-Ray recorder fixture
241241
"""
242-
client = await test_client(ServerTest.app(loop=loop))
242+
client = await aiohttp_client(ServerTest.app(loop=loop))
243243

244244
resp = await client.get('/unauthorized')
245245
assert resp.status == 401
@@ -256,8 +256,8 @@ async def test_unhauthorized(test_client, loop, recorder):
256256
assert response['status'] == 401
257257

258258

259-
async def test_response_trace_header(test_client, loop, recorder):
260-
client = await test_client(ServerTest.app(loop=loop))
259+
async def test_response_trace_header(aiohttp_client, loop, recorder):
260+
client = await aiohttp_client(ServerTest.app(loop=loop))
261261
resp = await client.get('/')
262262
xray_header = resp.headers[http.XRAY_HEADER]
263263
segment = recorder.emitter.pop()
@@ -266,15 +266,15 @@ async def test_response_trace_header(test_client, loop, recorder):
266266
assert expected in xray_header
267267

268268

269-
async def test_concurrent(test_client, loop, recorder):
269+
async def test_concurrent(aiohttp_client, loop, recorder):
270270
"""
271271
Test multiple concurrent requests
272272
273-
:param test_client: AioHttp test client fixture
273+
:param aiohttp_client: AioHttp test client fixture
274274
:param loop: Eventloop fixture
275275
:param recorder: X-Ray recorder fixture
276276
"""
277-
client = await test_client(ServerTest.app(loop=loop))
277+
client = await aiohttp_client(ServerTest.app(loop=loop))
278278

279279
recorder.emitter = CustomStubbedEmitter()
280280

@@ -292,16 +292,16 @@ async def get_delay():
292292
assert len(ids) == len(set(ids))
293293

294294

295-
async def test_disabled_sdk(test_client, loop, recorder):
295+
async def test_disabled_sdk(aiohttp_client, loop, recorder):
296296
"""
297297
Test a normal response when the SDK is disabled.
298298
299-
:param test_client: AioHttp test client fixture
299+
:param aiohttp_client: AioHttp test client fixture
300300
:param loop: Eventloop fixture
301301
:param recorder: X-Ray recorder fixture
302302
"""
303303
global_sdk_config.set_sdk_enabled(False)
304-
client = await test_client(ServerTest.app(loop=loop))
304+
client = await aiohttp_client(ServerTest.app(loop=loop))
305305

306306
resp = await client.get('/')
307307
assert resp.status == 200

tox.ini

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ deps =
7373
ext-aiobotocore: aiobotocore >= 0.10.0
7474
ext-aiobotocore: pytest-asyncio
7575

76-
ext-aiohttp: aiohttp >= 3.0.0
77-
; Breaking change where the `test_client` fixture was renamed.
78-
; Also, the stable version is only supported for Python 3.7+
79-
ext-aiohttp: pytest-aiohttp < 1.0.0
76+
ext-aiohttp: aiohttp >= 3.3.0
77+
ext-aiohttp: pytest-aiohttp
8078

8179
ext-httpx: httpx >= 0.20
8280
ext-httpx: pytest-asyncio >= 0.19

0 commit comments

Comments
 (0)