summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-08-17 09:05:17 (GMT)
committerGitHub <noreply@github.com>2022-08-17 09:05:17 (GMT)
commit36517101dd80cae93da379e95e98a688c52935b7 (patch)
tree1cca6769ff57f9b2c9f388b7819b8c81e686e2a8 /Lib/unittest
parentda0aa518bf5e6ac9de444a405c40649cfb0245eb (diff)
downloadcpython-36517101dd80cae93da379e95e98a688c52935b7.zip
cpython-36517101dd80cae93da379e95e98a688c52935b7.tar.gz
cpython-36517101dd80cae93da379e95e98a688c52935b7.tar.bz2
gh-95736: Fix event loop creation in IsolatedAsyncioTestCase (GH-96033)
It should be created before calling the setUp() method, but after checking for skipping a test. Automerge-Triggered-By: GH:tiran
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/async_case.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/unittest/async_case.py b/Lib/unittest/async_case.py
index 8b06fad..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)
@@ -116,10 +120,6 @@ class IsolatedAsyncioTestCase(TestCase):
assert self._asyncioRunner is None, 'asyncio runner is already initialized'
runner = asyncio.Runner(debug=True)
self._asyncioRunner = runner
- # 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.
- runner.get_loop()
def _tearDownAsyncioRunner(self):
runner = self._asyncioRunner