summaryrefslogtreecommitdiffstats
path: root/Lib/unittest/async_case.py
diff options
context:
space:
mode:
authorKumar Aditya <59607654+kumaraditya303@users.noreply.github.com>2022-08-18 13:42:16 (GMT)
committerGitHub <noreply@github.com>2022-08-18 13:42:16 (GMT)
commitb68ea2a3e4ae6872e5bb69a0deded21f98c1eecc (patch)
treec7d1544e654ed26a516e0c832d66c34559903292 /Lib/unittest/async_case.py
parent1b9b4856c86f3895445d8bd57a7ab18fc5cc9b20 (diff)
downloadcpython-b68ea2a3e4ae6872e5bb69a0deded21f98c1eecc.zip
cpython-b68ea2a3e4ae6872e5bb69a0deded21f98c1eecc.tar.gz
cpython-b68ea2a3e4ae6872e5bb69a0deded21f98c1eecc.tar.bz2
[3.11] GH-95736: fix IsolatedAsyncioTestCase to initialize Runner bef… (#96042)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Lib/unittest/async_case.py')
-rw-r--r--Lib/unittest/async_case.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/unittest/async_case.py b/Lib/unittest/async_case.py
index a90eed9..3457e92 100644
--- a/Lib/unittest/async_case.py
+++ b/Lib/unittest/async_case.py
@@ -79,6 +79,10 @@ class IsolatedAsyncioTestCase(TestCase):
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)