diff options
author | Nikita Sobolev <mail@sobolevn.me> | 2024-06-12 14:50:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-12 14:50:58 (GMT) |
commit | fabcf6bc8f89f008319442dea614d5cbeb959544 (patch) | |
tree | f829bb39a272fe4f63a9c91234fe887ad458d0dc /Lib/unittest/async_case.py | |
parent | 92c9c6ae147e1e658bbc8d454f8c7b2c4dea31d1 (diff) | |
download | cpython-fabcf6bc8f89f008319442dea614d5cbeb959544.zip cpython-fabcf6bc8f89f008319442dea614d5cbeb959544.tar.gz cpython-fabcf6bc8f89f008319442dea614d5cbeb959544.tar.bz2 |
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>
Diffstat (limited to 'Lib/unittest/async_case.py')
-rw-r--r-- | Lib/unittest/async_case.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/unittest/async_case.py b/Lib/unittest/async_case.py index 63ff6a5..bd06eb3 100644 --- a/Lib/unittest/async_case.py +++ b/Lib/unittest/async_case.py @@ -90,9 +90,13 @@ class IsolatedAsyncioTestCase(TestCase): 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) |