diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-08-16 15:52:06 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-16 15:52:06 (GMT) |
commit | 9d515997f943b7b510268448f372dabcbf957858 (patch) | |
tree | 8380d58fa0069ec48a38d6d99057db6168a98b12 /Lib/test/test_unittest/test_async_case.py | |
parent | 5a8c15819c27c516e5b75b7c9d89eacdb16b77c3 (diff) | |
download | cpython-9d515997f943b7b510268448f372dabcbf957858.zip cpython-9d515997f943b7b510268448f372dabcbf957858.tar.gz cpython-9d515997f943b7b510268448f372dabcbf957858.tar.bz2 |
GH-95736: fix IsolatedAsyncioTestCase to initialize Runner before calling setup functions (#95898)
Diffstat (limited to 'Lib/test/test_unittest/test_async_case.py')
-rw-r--r-- | Lib/test/test_unittest/test_async_case.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_unittest/test_async_case.py b/Lib/test/test_unittest/test_async_case.py index beadcac..f59fc76 100644 --- a/Lib/test/test_unittest/test_async_case.py +++ b/Lib/test/test_unittest/test_async_case.py @@ -434,6 +434,21 @@ class TestAsyncCase(unittest.TestCase): 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() |