Fix up docstring for tests (#5090)

This commit is contained in:
Johann Kellerman 2016-12-28 20:04:59 +02:00 committed by GitHub
parent 98efbbc129
commit f0b1874d2d
19 changed files with 61 additions and 59 deletions

View file

@ -86,6 +86,7 @@ class RunCoroutineThreadsafeTests(test_utils.TestCase):
"""Test case for asyncio.run_coroutine_threadsafe."""
def setUp(self):
"""Test setup method."""
self.loop = asyncio.new_event_loop()
self.set_event_loop(self.loop) # Will cleanup properly
@ -126,16 +127,14 @@ class RunCoroutineThreadsafeTests(test_utils.TestCase):
self.assertEqual(result, 3)
def test_run_coroutine_threadsafe_with_exception(self):
"""Test coroutine submission from a thread to an event loop
when an exception is raised."""
"""Test coroutine submission from thread to event loop on exception."""
future = self.loop.run_in_executor(None, self.target, True)
with self.assertRaises(RuntimeError) as exc_context:
self.loop.run_until_complete(future)
self.assertIn("Fail!", exc_context.exception.args)
def test_run_coroutine_threadsafe_with_timeout(self):
"""Test coroutine submission from a thread to an event loop
when a timeout is raised."""
"""Test coroutine submission from thread to event loop on timeout."""
callback = lambda: self.target(timeout=0) # noqa
future = self.loop.run_in_executor(None, callback)
with self.assertRaises(asyncio.TimeoutError):
@ -146,8 +145,7 @@ class RunCoroutineThreadsafeTests(test_utils.TestCase):
self.assertTrue(task.done())
def test_run_coroutine_threadsafe_task_cancelled(self):
"""Test coroutine submission from a tread to an event loop
when the task is cancelled."""
"""Test coroutine submission from tread to event loop on cancel."""
callback = lambda: self.target(cancel=True) # noqa
future = self.loop.run_in_executor(None, callback)
with self.assertRaises(asyncio.CancelledError):