Skip to content

Commit

Permalink
gh-95736: Fix event loop creation in IsolatedAsyncioTestCase (GH-96033)
Browse files Browse the repository at this point in the history
It should be created before calling the setUp() method, but after
checking for skipping a test.

Automerge-Triggered-By: GH:tiran
  • Loading branch information
serhiy-storchaka authored Aug 17, 2022
1 parent da0aa51 commit 3651710
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Lib/unittest/async_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ async def enterAsyncContext(self, cm):
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)

Expand Down Expand Up @@ -116,10 +120,6 @@ def _setupAsyncioRunner(self):
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
Expand Down

0 comments on commit 3651710

Please sign in to comment.