Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Closed
Description
demo reproducer:
importunittestimportasyncioclassDemoTestCase1(unittest.IsolatedAsyncioTestCase):defsetUp(self):self.loop=asyncio.get_event_loop_policy().get_event_loop()asyncdeftest_demo(self):print("hello!")classDemoTestCase2(unittest.IsolatedAsyncioTestCase):defsetUp(self):self.loop=asyncio.get_event_loop_policy().get_event_loop()asyncdeftest_demo(self):print("hello!")if__name__=="__main__":unittest.main()
see also#93896
graingert@conscientious testing310 ~/projects python3.10 foo.py hello!.hello!.----------------------------------------------------------------------Ran 2 tests in 0.002sOK
graingert@conscientious testing310 ~/projects python3.11 foo.py hello!.E======================================================================ERROR: test_demo (__main__.DemoTestCase2.test_demo)----------------------------------------------------------------------Traceback (most recent call last): File "/usr/lib/python3.11/unittest/async_case.py", line 82, in _callSetUp self._asyncioTestContext.run(self.setUp) File "/home/graingert/projects/foo.py", line 14, in setUp self.loop = asyncio.get_event_loop_policy().get_event_loop() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/asyncio/events.py", line 677, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.'RuntimeError: There is no current event loop in thread 'MainThread'.----------------------------------------------------------------------Ran 2 tests in 0.002sFAILED (errors=1)
it looks like this is becauseasyncio.Runner
callsasyncio.set_event_loop(
inRunner.run
Metadata
Metadata
Assignees
Labels
Projects
Status
Todo