-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
gh-96030: IsolatedAsyncioTestCase: don't create asyncio runner for skipped tests #96031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,17 +79,26 @@ async def enterAsyncContext(self, cm): | |
return result | ||
|
||
def _callSetUp(self): | ||
self._asyncioTestContext.run(self.setUp) | ||
self._callAsync(self.asyncSetUp) | ||
self._setupAsyncioRunner() | ||
try: | ||
self._asyncioTestContext.run(self.setUp) | ||
self._callAsync(self.asyncSetUp) | ||
except Exception: | ||
# _callTearDown is not called when _callSetUp fails. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that |
||
self._tearDownAsyncioRunner() | ||
raise | ||
|
||
def _callTestMethod(self, method): | ||
if self._callMaybeAsync(method) is not None: | ||
warnings.warn(f'It is deprecated to return a value!=None from a ' | ||
f'test case ({method})', DeprecationWarning, stacklevel=4) | ||
|
||
def _callTearDown(self): | ||
self._callAsync(self.asyncTearDown) | ||
self._asyncioTestContext.run(self.tearDown) | ||
try: | ||
self._callAsync(self.asyncTearDown) | ||
self._asyncioTestContext.run(self.tearDown) | ||
finally: | ||
self._tearDownAsyncioRunner() | ||
|
||
def _callCleanup(self, function, *args, **kwargs): | ||
self._callMaybeAsync(function, *args, **kwargs) | ||
|
@@ -125,18 +134,6 @@ def _tearDownAsyncioRunner(self): | |
runner = self._asyncioRunner | ||
runner.close() | ||
|
||
def run(self, result=None): | ||
self._setupAsyncioRunner() | ||
try: | ||
return super().run(result) | ||
finally: | ||
self._tearDownAsyncioRunner() | ||
|
||
def debug(self): | ||
self._setupAsyncioRunner() | ||
super().debug() | ||
self._tearDownAsyncioRunner() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this used to not be called on an exception in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also I think you fixed this #96021 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by "this"? The function call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right but it used to not get called when debug failed, and now it does? So I think you fixed two bugs |
||
|
||
def __del__(self): | ||
if self._asyncioRunner is not None: | ||
self._tearDownAsyncioRunner() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The ``run`` method of :class:`unittest.IsolatedAsyncioTestCase` | ||
no longer sets up an asyncio runner if a test case or class is skipped. |
Uh oh!
There was an error while loading. Please reload this page.