mirror of
https://github.com/python/cpython.git
synced 2025-10-31 21:51:50 +00:00
gh-120388: Improve deprecation warning message, when test returns non-None (#120401)
Co-authored-by: Alex Waygood <alex.waygood@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
92c9c6ae14
commit
fabcf6bc8f
5 changed files with 44 additions and 6 deletions
|
|
@ -90,9 +90,13 @@ def _callSetUp(self):
|
|||
self._callAsync(self.asyncSetUp)
|
||||
|
||||
def _callTestMethod(self, method):
|
||||
if self._callMaybeAsync(method) is not None:
|
||||
warnings.warn(f'It is deprecated to return a value that is not None from a '
|
||||
f'test case ({method})', DeprecationWarning, stacklevel=4)
|
||||
result = self._callMaybeAsync(method)
|
||||
if result is not None:
|
||||
msg = (
|
||||
f'It is deprecated to return a value that is not None '
|
||||
f'from a test case ({method} returned {type(result).__name__!r})',
|
||||
)
|
||||
warnings.warn(msg, DeprecationWarning, stacklevel=4)
|
||||
|
||||
def _callTearDown(self):
|
||||
self._callAsync(self.asyncTearDown)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue