summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_base_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-11-20 14:03:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-11-20 14:03:52 (GMT)
commit2d99d93d11e7908a51fde8de27b7a3584d23cf46 (patch)
treee52008207c7b1af6298fd742551508e5f0215ec7 /Lib/test/test_asyncio/test_base_events.py
parentc1ad35aae84d5cda4f73696844a87d7764224150 (diff)
downloadcpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.zip
cpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.tar.gz
cpython-2d99d93d11e7908a51fde8de27b7a3584d23cf46.tar.bz2
asyncio: Coroutine objects are now rejected with a TypeError by the following
functions: * add_signal_handler() * call_at() * call_later() * call_soon() * call_soon_threadsafe() * run_in_executor() Fix also the error message of add_signal_handler() (fix the name of the function).
Diffstat (limited to 'Lib/test/test_asyncio/test_base_events.py')
-rw-r--r--Lib/test/test_asyncio/test_base_events.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index d61a64c..0aa0117 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -1107,19 +1107,23 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
def test_call_coroutine(self):
@asyncio.coroutine
- def coroutine_function():
+ def simple_coroutine():
pass
- with self.assertRaises(TypeError):
- self.loop.call_soon(coroutine_function)
- with self.assertRaises(TypeError):
- self.loop.call_soon_threadsafe(coroutine_function)
- with self.assertRaises(TypeError):
- self.loop.call_later(60, coroutine_function)
- with self.assertRaises(TypeError):
- self.loop.call_at(self.loop.time() + 60, coroutine_function)
- with self.assertRaises(TypeError):
- self.loop.run_in_executor(None, coroutine_function)
+ coro_func = simple_coroutine
+ coro_obj = coro_func()
+ self.addCleanup(coro_obj.close)
+ for func in (coro_func, coro_obj):
+ with self.assertRaises(TypeError):
+ self.loop.call_soon(func)
+ with self.assertRaises(TypeError):
+ self.loop.call_soon_threadsafe(func)
+ with self.assertRaises(TypeError):
+ self.loop.call_later(60, func)
+ with self.assertRaises(TypeError):
+ self.loop.call_at(self.loop.time() + 60, func)
+ with self.assertRaises(TypeError):
+ self.loop.run_in_executor(None, func)
@mock.patch('asyncio.base_events.logger')
def test_log_slow_callbacks(self, m_logger):