Skip to content

Commit be03eda

Browse files
committed
avoid setting the policy in test_asyngen
1 parent bba25df commit be03eda

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎Lib/test/test_asyncgen.py‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,6 +2012,9 @@ async def agenfn():
20122012
gc_collect() # does not warn unawaited
20132013

20142014

2015+
_asyncio_run = functools.partial(asyncio.run, loop_factory=asyncio.EventLoop)
2016+
2017+
20152018
@requires_working_socket()
20162019
class AsyncGenAsyncioRunTestCase(unittest.TestCase):
20172020
def test_async_gen_asyncio_shutdown_02(self):
@@ -2032,7 +2035,7 @@ async def main():
20322035
async for i in it:
20332036
break
20342037

2035-
asyncio.run(main())
2038+
_asyncio_run(main())
20362039

20372040
self.assertEqual(messages, [])
20382041

@@ -2057,7 +2060,7 @@ async def main():
20572060
async for i in it:
20582061
break
20592062

2060-
asyncio.run(main())
2063+
_asyncio_run(main())
20612064

20622065
message, = messages
20632066
self.assertEqual(message['asyncgen'], it)
@@ -2086,7 +2089,7 @@ async def main():
20862089
break
20872090
gc_collect()
20882091

2089-
asyncio.run(main())
2092+
_asyncio_run(main())
20902093

20912094
message, = messages
20922095
self.assertIsInstance(message['exception'], ZeroDivisionError)
@@ -2113,7 +2116,7 @@ async def main():
21132116
async for i in async_iterate():
21142117
break
21152118

2116-
asyncio.run(main())
2119+
_asyncio_run(main())
21172120

21182121
self.assertEqual([], messages)
21192122
gc_collect()

0 commit comments

Comments
 (0)