summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2015-10-05 23:20:00 (GMT)
committerGuido van Rossum <guido@python.org>2015-10-05 23:20:00 (GMT)
commit601953b67958572162d0ab7d3f24c07340ad9dbb (patch)
tree7341a077fa62b61dd3916b405b19fd74a926ffe4 /Lib/test/test_asyncio
parentb9bf913ab32d27d221fb765fd90d64d07e926000 (diff)
downloadcpython-601953b67958572162d0ab7d3f24c07340ad9dbb.zip
cpython-601953b67958572162d0ab7d3f24c07340ad9dbb.tar.gz
cpython-601953b67958572162d0ab7d3f24c07340ad9dbb.tar.bz2
Docs and one small improvement for issue #25304, by Vincent Michel.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_tasks.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_tasks.py b/Lib/test/test_asyncio/test_tasks.py
index 8ec5d9c..9772bae 100644
--- a/Lib/test/test_asyncio/test_tasks.py
+++ b/Lib/test/test_asyncio/test_tasks.py
@@ -2166,6 +2166,27 @@ class RunCoroutineThreadsafeTests(test_utils.TestCase):
with self.assertRaises(asyncio.CancelledError):
self.loop.run_until_complete(future)
+ def test_run_coroutine_threadsafe_task_factory_exception(self):
+ """Test coroutine submission from a tread to an event loop
+ when the task factory raise an exception."""
+ # Clear the time generator
+ asyncio.ensure_future(self.add(1, 2), loop=self.loop)
+ # Schedule the target
+ future = self.loop.run_in_executor(None, self.target)
+ # Set corrupted task factory
+ self.loop.set_task_factory(lambda loop, coro: wrong_name)
+ # Set exception handler
+ callback = test_utils.MockCallback()
+ self.loop.set_exception_handler(callback)
+ # Run event loop
+ with self.assertRaises(NameError) as exc_context:
+ self.loop.run_until_complete(future)
+ # Check exceptions
+ self.assertIn('wrong_name', exc_context.exception.args[0])
+ self.assertEqual(len(callback.call_args_list), 1)
+ (loop, context), kwargs = callback.call_args
+ self.assertEqual(context['exception'], exc_context.exception)
+
if __name__ == '__main__':
unittest.main()