Skip to content

Commit 200e140

Browse files
fantix1st1
authored andcommitted
Fix tests for Python 3.9
1 parent 1fd9066 commit 200e140

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,9 +636,9 @@ def test_shutdown_asyncgens_02(self):
636636

637637
def logger(loop, context):
638638
nonlocal logged
639-
self.assertIn('asyncgen', context)
640639
expected = 'an error occurred during closing of asynchronous'
641640
if expected in context['message']:
641+
self.assertIn('asyncgen', context)
642642
logged += 1
643643

644644
waiter = self._compile_agen('''async def waiter(timeout):

tests/test_process_spawning.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ async def run(loop):
2020
dummy_workers = [simulate_loop_activity(loop, event)
2121
for _ in range(5)]
2222
spawn_worker = spawn_external_process(loop, event)
23-
done, pending = await asyncio.wait([spawn_worker] + dummy_workers)
23+
done, pending = await asyncio.wait([
24+
asyncio.ensure_future(fut)
25+
for fut in ([spawn_worker] + dummy_workers)
26+
])
2427
exceptions = [result.exception()
2528
for result in done if result.exception()]
2629
if exceptions:

tests/test_sockets.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,13 @@ async def client(addr):
223223
with sock_client:
224224
await self.loop.sock_connect(sock_client, addr)
225225
_, pending_read_futs = await asyncio.wait(
226-
[self.loop.sock_recv(sock_client, 1)],
227-
timeout=1)
226+
[
227+
asyncio.ensure_future(
228+
self.loop.sock_recv(sock_client, 1)
229+
)
230+
],
231+
timeout=1,
232+
)
228233

229234
async def send_server_data():
230235
# Wait a little bit to let reader future cancel and
@@ -273,8 +278,13 @@ async def client(addr):
273278
with sock_client:
274279
await self.loop.sock_connect(sock_client, addr)
275280
_, pending_read_futs = await asyncio.wait(
276-
[self.loop.sock_recv(sock_client, 1)],
277-
timeout=1)
281+
[
282+
asyncio.ensure_future(
283+
self.loop.sock_recv(sock_client, 1)
284+
)
285+
],
286+
timeout=1,
287+
)
278288

279289
# server can send the data in a random time, even before
280290
# the previous result future has cancelled.

tests/test_tcp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,8 +2526,13 @@ def unwrap_server(sock):
25262526
except ssl.SSLError as ex:
25272527
# Since OpenSSL 1.1.1, it raises "application data after
25282528
# close notify"
2529+
# Python < 3.8:
25292530
if ex.reason == 'KRB5_S_INIT':
25302531
break
2532+
# Python >= 3.8:
2533+
if ex.reason == 'APPLICATION_DATA_AFTER_CLOSE_NOTIFY':
2534+
break
2535+
raise ex
25312536
except OSError as ex:
25322537
# OpenSSL < 1.1.1
25332538
if ex.errno != 0:

tests/test_udp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def datagram_received(self, data, addr):
308308

309309
s2.send(b'hello, socketpair')
310310
addr = self.loop.run_until_complete(
311-
asyncio.wait_for(peername, 1, loop=self.loop))
311+
asyncio.wait_for(peername, 1))
312312
if sys.platform.startswith('linux'):
313313
self.assertEqual(addr, None)
314314
else:
@@ -322,7 +322,7 @@ def datagram_received(self, data, addr):
322322
tr.sendto(data)
323323
result = self.loop.run_until_complete(asyncio.wait_for(
324324
self.loop.run_in_executor(None, s2.recv, 1024),
325-
1, loop=self.loop))
325+
1))
326326
self.assertEqual(data, result)
327327

328328
tr.close()

0 commit comments

Comments
 (0)