mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
asyncio, Tulip issue 126: call_soon(), call_soon_threadsafe(), call_later(),
call_at() and run_in_executor() now raise a TypeError if the callback is a coroutine function.
This commit is contained in:
parent
1db2ba3a92
commit
a125497ea3
6 changed files with 39 additions and 13 deletions
|
@ -2,8 +2,6 @@
|
|||
|
||||
import gc
|
||||
import unittest
|
||||
import unittest.mock
|
||||
from unittest.mock import Mock
|
||||
|
||||
import asyncio
|
||||
from asyncio import test_utils
|
||||
|
@ -1358,7 +1356,7 @@ class GatherTestsBase:
|
|||
def _check_success(self, **kwargs):
|
||||
a, b, c = [asyncio.Future(loop=self.one_loop) for i in range(3)]
|
||||
fut = asyncio.gather(*self.wrap_futures(a, b, c), **kwargs)
|
||||
cb = Mock()
|
||||
cb = test_utils.MockCallback()
|
||||
fut.add_done_callback(cb)
|
||||
b.set_result(1)
|
||||
a.set_result(2)
|
||||
|
@ -1380,7 +1378,7 @@ class GatherTestsBase:
|
|||
def test_one_exception(self):
|
||||
a, b, c, d, e = [asyncio.Future(loop=self.one_loop) for i in range(5)]
|
||||
fut = asyncio.gather(*self.wrap_futures(a, b, c, d, e))
|
||||
cb = Mock()
|
||||
cb = test_utils.MockCallback()
|
||||
fut.add_done_callback(cb)
|
||||
exc = ZeroDivisionError()
|
||||
a.set_result(1)
|
||||
|
@ -1399,7 +1397,7 @@ class GatherTestsBase:
|
|||
a, b, c, d = [asyncio.Future(loop=self.one_loop) for i in range(4)]
|
||||
fut = asyncio.gather(*self.wrap_futures(a, b, c, d),
|
||||
return_exceptions=True)
|
||||
cb = Mock()
|
||||
cb = test_utils.MockCallback()
|
||||
fut.add_done_callback(cb)
|
||||
exc = ZeroDivisionError()
|
||||
exc2 = RuntimeError()
|
||||
|
@ -1460,7 +1458,7 @@ class FutureGatherTests(GatherTestsBase, unittest.TestCase):
|
|||
def test_one_cancellation(self):
|
||||
a, b, c, d, e = [asyncio.Future(loop=self.one_loop) for i in range(5)]
|
||||
fut = asyncio.gather(a, b, c, d, e)
|
||||
cb = Mock()
|
||||
cb = test_utils.MockCallback()
|
||||
fut.add_done_callback(cb)
|
||||
a.set_result(1)
|
||||
b.cancel()
|
||||
|
@ -1479,7 +1477,7 @@ class FutureGatherTests(GatherTestsBase, unittest.TestCase):
|
|||
a, b, c, d, e, f = [asyncio.Future(loop=self.one_loop)
|
||||
for i in range(6)]
|
||||
fut = asyncio.gather(a, b, c, d, e, f, return_exceptions=True)
|
||||
cb = Mock()
|
||||
cb = test_utils.MockCallback()
|
||||
fut.add_done_callback(cb)
|
||||
a.set_result(1)
|
||||
zde = ZeroDivisionError()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue