mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-41322: Add unit tests for deprecation of test return values (GH-27846)
Also fix the traceback of warnings.
This commit is contained in:
parent
6dd1cdb0cf
commit
b1db308c61
6 changed files with 50 additions and 2 deletions
|
@ -306,6 +306,26 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
|
|||
|
||||
Foo('test').run()
|
||||
|
||||
def test_deprecation_of_return_val_from_test(self):
|
||||
# Issue 41322 - deprecate return of value!=None from a test
|
||||
class Foo(unittest.TestCase):
|
||||
def test1(self):
|
||||
return 1
|
||||
def test2(self):
|
||||
yield 1
|
||||
|
||||
with self.assertWarns(DeprecationWarning) as w:
|
||||
Foo('test1').run()
|
||||
self.assertIn('It is deprecated to return a value!=None', str(w.warnings[0].message))
|
||||
self.assertIn('test1', str(w.warnings[0].message))
|
||||
self.assertEqual(w.warnings[0].filename, __file__)
|
||||
|
||||
with self.assertWarns(DeprecationWarning) as w:
|
||||
Foo('test2').run()
|
||||
self.assertIn('It is deprecated to return a value!=None', str(w.warnings[0].message))
|
||||
self.assertIn('test2', str(w.warnings[0].message))
|
||||
self.assertEqual(w.warnings[0].filename, __file__)
|
||||
|
||||
def _check_call_order__subtests(self, result, events, expected_events):
|
||||
class Foo(Test.LoggingTestCase):
|
||||
def test(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue