Skip to content

Commit ebc4103

Browse files
committed
test[fix]: Pass parameters to aiohttp correctly
Apparently the parameter passing in our `aiohttp` tests were incorrect, and was depending on a `yarl` bug [1] that was fixed [2] in `1.9.0`, and with this new yarl version, our tests started to fail. This fix corrects the parameter passing, so we can use the latest `yarl`. [1] aio-libs/yarl#723 [2] aio-libs/yarl#792 Signed-off-by: Ferenc Géczi <[email protected]>
1 parent 78bc436 commit ebc4103

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

tests/frameworks/test_aiohttp_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
class TestAiohttp(unittest.TestCase):
1818

19-
async def fetch(self, session, url, headers=None):
19+
async def fetch(self, session, url, headers=None, params=None):
2020
try:
21-
async with session.get(url, headers=headers) as response:
21+
async with session.get(url, headers=headers, params=params) as response:
2222
return response
2323
except aiohttp.web_exceptions.HTTPException:
2424
pass
@@ -296,7 +296,7 @@ def test_client_get_with_params_to_scrub(self):
296296
async def test():
297297
with async_tracer.start_active_span('test'):
298298
async with aiohttp.ClientSession() as session:
299-
return await self.fetch(session, testenv["wsgi_server"] + "/?secret=yeah")
299+
return await self.fetch(session, testenv["wsgi_server"], params={"secret": "yeah"})
300300

301301
response = self.loop.run_until_complete(test())
302302

tests/frameworks/test_aiohttp_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
class TestAiohttpServer(unittest.TestCase):
1717

18-
async def fetch(self, session, url, headers=None):
18+
async def fetch(self, session, url, headers=None, params=None):
1919
try:
20-
async with session.get(url, headers=headers) as response:
20+
async with session.get(url, headers=headers, params=params) as response:
2121
return response
2222
except aiohttp.web_exceptions.HTTPException:
2323
pass
@@ -185,7 +185,7 @@ def test_server_get_with_params_to_scrub(self):
185185
async def test():
186186
with async_tracer.start_active_span('test'):
187187
async with aiohttp.ClientSession() as session:
188-
return await self.fetch(session, testenv["aiohttp_server"] + "/?secret=iloveyou")
188+
return await self.fetch(session, testenv["aiohttp_server"], params={"secret": "iloveyou"})
189189

190190
response = self.loop.run_until_complete(test())
191191

@@ -254,7 +254,7 @@ async def test():
254254
headers['X-Capture-This'] = 'this'
255255
headers['X-Capture-That'] = 'that'
256256

257-
return await self.fetch(session, testenv["aiohttp_server"] + "/?secret=iloveyou", headers=headers)
257+
return await self.fetch(session, testenv["aiohttp_server"], headers=headers, params={"secret": "iloveyou"})
258258

259259
response = self.loop.run_until_complete(test())
260260

tests/frameworks/test_tornado_server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919

2020
class TestTornadoServer(unittest.TestCase):
21-
async def fetch(self, session, url, headers=None):
21+
async def fetch(self, session, url, headers=None, params=None):
2222
try:
23-
async with session.get(url, headers=headers) as response:
23+
async with session.get(url, headers=headers, params=params) as response:
2424
return response
2525
except aiohttp.web_exceptions.HTTPException:
2626
pass
@@ -456,7 +456,7 @@ def test_get_with_params_to_scrub(self):
456456
async def test():
457457
with async_tracer.start_active_span('test'):
458458
async with aiohttp.ClientSession() as session:
459-
return await self.fetch(session, testenv["tornado_server"] + "/?secret=yeah")
459+
return await self.fetch(session, testenv["tornado_server"], params={"secret": "yeah"})
460460

461461
response = tornado.ioloop.IOLoop.current().run_sync(test)
462462

@@ -525,7 +525,7 @@ async def test():
525525
headers['X-Capture-This'] = 'this'
526526
headers['X-Capture-That'] = 'that'
527527

528-
return await self.fetch(session, testenv["tornado_server"] + "/?secret=iloveyou", headers=headers)
528+
return await self.fetch(session, testenv["tornado_server"], headers=headers, params={"secret": "iloveyou"})
529529

530530
response = tornado.ioloop.IOLoop.current().run_sync(test)
531531

tests/requirements-307.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,3 @@ spyne>=2.14.0
4848
tornado>=4.5.3,<6.0
4949
uvicorn>=0.13.4
5050
urllib3[secure]<1.27,>=1.26.5
51-
yarl==1.8.2

tests/requirements-310-with-tornado.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,3 @@ spyne>=2.14.0
3838

3939
uvicorn>=0.13.4
4040
urllib3[secure]<1.27,>=1.26.5
41-
yarl==1.8.2

tests/requirements-310.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ spyne>=2.14.0
4040

4141
uvicorn>=0.13.4
4242
urllib3[secure]<1.27,>=1.26.5
43-
yarl==1.8.2

tests/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,3 @@ spyne>=2.14.0
3939
tornado>=4.5.3,<6.0
4040
uvicorn>=0.13.4
4141
urllib3[secure]<1.27,>=1.26.5
42-
yarl==1.8.2

0 commit comments

Comments
 (0)