return result
def _callSetUp(self):
+ # Force loop to be initialized and set as the current loop
+ # so that setUp functions can use get_event_loop() and get the
+ # correct loop instance.
+ self._asyncioRunner.get_loop()
self._asyncioTestContext.run(self.setUp)
self._callAsync(self.asyncSetUp)
test.doCleanups()
self.assertEqual(events, ['asyncSetUp', 'test', 'cleanup'])
+ def test_setup_get_event_loop(self):
+ # See https://github.com/python/cpython/issues/95736
+ # Make sure the default event loop is not used
+ asyncio.set_event_loop(None)
+
+ class TestCase1(unittest.IsolatedAsyncioTestCase):
+ def setUp(self):
+ asyncio.get_event_loop_policy().get_event_loop()
+
+ async def test_demo1(self):
+ pass
+
+ test = TestCase1('test_demo1')
+ result = test.run()
+ self.assertTrue(result.wasSuccessful())
if __name__ == "__main__":
unittest.main()