bpo-32357: Fix tests in refleak mode (#4989)
This commit is contained in:
parent
c0919c27c6
commit
558aa30f79
|
@ -66,6 +66,20 @@ def _test_get_event_loop_new_process__sub_proc():
|
||||||
return loop.run_until_complete(doit())
|
return loop.run_until_complete(doit())
|
||||||
|
|
||||||
|
|
||||||
|
class CoroLike:
|
||||||
|
def send(self, v):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def throw(self, *exc):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __await__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
ONLYCERT = data_file('ssl_cert.pem')
|
ONLYCERT = data_file('ssl_cert.pem')
|
||||||
ONLYKEY = data_file('ssl_key.pem')
|
ONLYKEY = data_file('ssl_key.pem')
|
||||||
SIGNED_CERTFILE = data_file('keycert3.pem')
|
SIGNED_CERTFILE = data_file('keycert3.pem')
|
||||||
|
@ -2365,20 +2379,7 @@ class HandleTests(test_utils.TestCase):
|
||||||
# collections.abc.Coroutine, but lack cr_core or gi_code attributes
|
# collections.abc.Coroutine, but lack cr_core or gi_code attributes
|
||||||
# (such as ones compiled with Cython).
|
# (such as ones compiled with Cython).
|
||||||
|
|
||||||
class Coro:
|
coro = CoroLike()
|
||||||
def send(self, v):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def throw(self, *exc):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __await__(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
coro = Coro()
|
|
||||||
coro.__name__ = 'AAA'
|
coro.__name__ = 'AAA'
|
||||||
self.assertTrue(asyncio.iscoroutine(coro))
|
self.assertTrue(asyncio.iscoroutine(coro))
|
||||||
self.assertEqual(coroutines._format_coroutine(coro), 'AAA()')
|
self.assertEqual(coroutines._format_coroutine(coro), 'AAA()')
|
||||||
|
@ -2389,10 +2390,10 @@ class HandleTests(test_utils.TestCase):
|
||||||
coro.cr_running = True
|
coro.cr_running = True
|
||||||
self.assertEqual(coroutines._format_coroutine(coro), 'BBB() running')
|
self.assertEqual(coroutines._format_coroutine(coro), 'BBB() running')
|
||||||
|
|
||||||
coro = Coro()
|
coro = CoroLike()
|
||||||
# Some coroutines might not have '__name__', such as
|
# Some coroutines might not have '__name__', such as
|
||||||
# built-in async_gen.asend().
|
# built-in async_gen.asend().
|
||||||
self.assertEqual(coroutines._format_coroutine(coro), 'Coro()')
|
self.assertEqual(coroutines._format_coroutine(coro), 'CoroLike()')
|
||||||
|
|
||||||
|
|
||||||
class TimerTests(unittest.TestCase):
|
class TimerTests(unittest.TestCase):
|
||||||
|
|
|
@ -10,6 +10,21 @@ import asyncio
|
||||||
from test.test_asyncio import utils as test_utils
|
from test.test_asyncio import utils as test_utils
|
||||||
|
|
||||||
|
|
||||||
|
# Test that asyncio.iscoroutine() uses collections.abc.Coroutine
|
||||||
|
class FakeCoro:
|
||||||
|
def send(self, value):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def throw(self, typ, val=None, tb=None):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def __await__(self):
|
||||||
|
yield
|
||||||
|
|
||||||
|
|
||||||
class BaseTest(test_utils.TestCase):
|
class BaseTest(test_utils.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -99,13 +114,6 @@ class CoroutineTests(BaseTest):
|
||||||
finally:
|
finally:
|
||||||
f.close() # silence warning
|
f.close() # silence warning
|
||||||
|
|
||||||
# Test that asyncio.iscoroutine() uses collections.abc.Coroutine
|
|
||||||
class FakeCoro:
|
|
||||||
def send(self, value): pass
|
|
||||||
def throw(self, typ, val=None, tb=None): pass
|
|
||||||
def close(self): pass
|
|
||||||
def __await__(self): yield
|
|
||||||
|
|
||||||
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
self.assertTrue(asyncio.iscoroutine(FakeCoro()))
|
||||||
|
|
||||||
def test_iscoroutinefunction(self):
|
def test_iscoroutinefunction(self):
|
||||||
|
|
Loading…
Reference in New Issue