Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add self.assertWarns()
  • Loading branch information
aeros committed Oct 29, 2019
commit 0e8997849b3ba3babbeb6872c8613af63c2ffc8c
13 changes: 8 additions & 5 deletions Lib/test/test_asyncio/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,12 +979,12 @@ def test_wait_duplicate_coroutines(self):
def coro(s):
return s
c = coro('test')

task =self.new_task(
task = self.new_task(
self.loop,
asyncio.wait([c, c, coro('spam')]))

done, pending = self.loop.run_until_complete(task)
with self.assertWarns(DeprecationWarning):
done, pending = self.loop.run_until_complete(task)

self.assertFalse(pending)
self.assertEqual(set(f.result() for f in done), {'test', 'spam'})
Expand Down Expand Up @@ -1346,7 +1346,9 @@ def gen():
futs = list(asyncio.as_completed(fs, loop=loop))
self.assertEqual(len(futs), 2)
waiter = asyncio.wait(futs)
done, pending = loop.run_until_complete(waiter)
# Deprecation from passing coros in futs to asyncio.wait()
with self.assertWarns(DeprecationWarning):
done, pending = loop.run_until_complete(waiter)
Comment thread
aeros marked this conversation as resolved.
self.assertEqual(set(f.result() for f in done), {'a', 'b'})

def test_as_completed_duplicate_coroutines(self):
Expand Down Expand Up @@ -1751,7 +1753,8 @@ async def inner():

async def outer():
nonlocal proof
d, p = await asyncio.wait([inner()])
with self.assertWarns(DeprecationWarning):
d, p = await asyncio.wait([inner()])
proof += 100

f = asyncio.ensure_future(outer(), loop=self.loop)
Expand Down