return task
elif futures.isfuture(coro_or_future):
if loop is not None and loop is not futures._get_loop(coro_or_future):
- raise ValueError('loop argument must agree with Future')
+ raise ValueError('The future belongs to a different loop than '
+ 'the one specified as the loop argument')
return coro_or_future
elif inspect.isawaitable(coro_or_future):
return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
with self.assertRaises(TypeError):
asyncio.ensure_future('ok')
+ def test_ensure_future_error_msg(self):
+ loop = asyncio.new_event_loop()
+ f = self.new_future(self.loop)
+ with self.assertRaisesRegex(ValueError, 'The future belongs to a '
+ 'different loop than the one specified as '
+ 'the loop argument'):
+ asyncio.ensure_future(f, loop=loop)
+ loop.close()
+
def test_get_stack(self):
T = None