diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2014-02-11 10:54:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2014-02-11 10:54:08 (GMT) |
commit | eb74876e9939bfa9e30cd2e8894ab827cc2296b4 (patch) | |
tree | 5fd1c34466f1a6e881a4ed29d2b5c0b6aa44847c /Lib/test/test_asyncio/test_tasks.py | |
parent | 4e8d2f25e23d1da33d414074485da8e374d98495 (diff) | |
download | cpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.zip cpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.tar.gz cpython-eb74876e9939bfa9e30cd2e8894ab827cc2296b4.tar.bz2 |
asyncio, Tulip issue 131: as_completed() and wait() now raises a TypeError if
the list of futures is not a list but a Future, Task or coroutine object
Diffstat (limited to 'Lib/test/test_asyncio/test_tasks.py')
-rw-r--r-- | Lib/test/test_asyncio/test_tasks.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py index 29bdaf5..6847de0 100644 --- a/Lib/test/test_asyncio/test_tasks.py +++ b/Lib/test/test_asyncio/test_tasks.py @@ -7,6 +7,11 @@ import asyncio from asyncio import test_utils +@asyncio.coroutine +def coroutine_function(): + pass + + class Dummy: def __repr__(self): @@ -1338,6 +1343,27 @@ class TaskTests(unittest.TestCase): child2.set_result(2) test_utils.run_briefly(self.loop) + def test_as_completed_invalid_args(self): + fut = asyncio.Future(loop=self.loop) + + # as_completed() expects a list of futures, not a future instance + self.assertRaises(TypeError, self.loop.run_until_complete, + asyncio.as_completed(fut, loop=self.loop)) + self.assertRaises(TypeError, self.loop.run_until_complete, + asyncio.as_completed(coroutine_function(), loop=self.loop)) + + def test_wait_invalid_args(self): + fut = asyncio.Future(loop=self.loop) + + # wait() expects a list of futures, not a future instance + self.assertRaises(TypeError, self.loop.run_until_complete, + asyncio.wait(fut, loop=self.loop)) + self.assertRaises(TypeError, self.loop.run_until_complete, + asyncio.wait(coroutine_function(), loop=self.loop)) + + # wait() expects at least a future + self.assertRaises(ValueError, self.loop.run_until_complete, + asyncio.wait([], loop=self.loop)) class GatherTestsBase: |