Skip to content

Commit b7f48eb

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 b3d605d commit b7f48eb

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
@@ -124,15 +124,15 @@ def recorder(loop):
124124
patcher.stop()
125125

126126

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

137137
resp = await client.get('/')
138138
assert resp.status == 200
@@ -148,15 +148,15 @@ async def test_ok(test_client, loop, recorder):
148148
assert response['status'] == 200
149149

150150

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

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

168168

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

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

185185

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

196196
resp = await client.get('/error')
197197
assert resp.status == 404
@@ -208,15 +208,15 @@ async def test_error(test_client, loop, recorder):
208208
assert response['status'] == 404
209209

210210

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

221221
with pytest.raises(Exception):
222222
await client.get('/exception')
@@ -235,15 +235,15 @@ async def test_exception(test_client, loop, recorder):
235235
assert exception.type == 'CancelledError'
236236

237237

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

248248
resp = await client.get('/unauthorized')
249249
assert resp.status == 401
@@ -260,8 +260,8 @@ async def test_unhauthorized(test_client, loop, recorder):
260260
assert response['status'] == 401
261261

262262

263-
async def test_response_trace_header(test_client, loop, recorder):
264-
client = await test_client(ServerTest.app(loop=loop))
263+
async def test_response_trace_header(aiohttp_client, loop, recorder):
264+
client = await aiohttp_client(ServerTest.app(loop=loop))
265265
resp = await client.get('/')
266266
xray_header = resp.headers[http.XRAY_HEADER]
267267
segment = recorder.emitter.pop()
@@ -270,15 +270,15 @@ async def test_response_trace_header(test_client, loop, recorder):
270270
assert expected in xray_header
271271

272272

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

283283
recorder.emitter = CustomStubbedEmitter()
284284

@@ -296,16 +296,16 @@ async def get_delay():
296296
assert len(ids) == len(set(ids))
297297

298298

299-
async def test_disabled_sdk(test_client, loop, recorder):
299+
async def test_disabled_sdk(aiohttp_client, loop, recorder):
300300
"""
301301
Test a normal response when the SDK is disabled.
302302
303-
:param test_client: AioHttp test client fixture
303+
:param aiohttp_client: AioHttp test client fixture
304304
:param loop: Eventloop fixture
305305
:param recorder: X-Ray recorder fixture
306306
"""
307307
global_sdk_config.set_sdk_enabled(False)
308-
client = await test_client(ServerTest.app(loop=loop))
308+
client = await aiohttp_client(ServerTest.app(loop=loop))
309309

310310
resp = await client.get('/')
311311
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)