mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-41322: added deprecation warning for tests returning value!=None (GH-27748)
This commit is contained in:
parent
0fd66e46b2
commit
3db42fc5ac
3 changed files with 10 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
import asyncio
|
||||
import inspect
|
||||
import warnings
|
||||
|
||||
from .case import TestCase
|
||||
|
||||
|
@ -62,7 +63,9 @@ class IsolatedAsyncioTestCase(TestCase):
|
|||
self._callAsync(self.asyncSetUp)
|
||||
|
||||
def _callTestMethod(self, method):
|
||||
self._callMaybeAsync(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)
|
||||
|
||||
def _callTearDown(self):
|
||||
self._callAsync(self.asyncTearDown)
|
||||
|
|
|
@ -546,7 +546,9 @@ class TestCase(object):
|
|||
self.setUp()
|
||||
|
||||
def _callTestMethod(self, method):
|
||||
method()
|
||||
if method() is not None:
|
||||
warnings.warn(f'It is deprecated to return a value!=None from a '
|
||||
f'test case ({method})', DeprecationWarning)
|
||||
|
||||
def _callTearDown(self):
|
||||
self.tearDown()
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
Added ``DeprecationWarning`` for tests and async tests that return a
|
||||
value!=None (as this may indicate an improperly written test, for example a
|
||||
test written as a generator function).
|
Loading…
Add table
Add a link
Reference in a new issue