@@ -325,18 +325,37 @@ def test3(self):
325
325
self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
326
326
self .assertIn ('test1' , str (w .warning ))
327
327
self .assertEqual (w .filename , __file__ )
328
+ self .assertIn ("returned 'int'" , str (w .warning ))
328
329
329
330
with self .assertWarns (DeprecationWarning ) as w :
330
331
Foo ('test2' ).run ()
331
332
self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
332
333
self .assertIn ('test2' , str (w .warning ))
333
334
self .assertEqual (w .filename , __file__ )
335
+ self .assertIn ("returned 'generator'" , str (w .warning ))
334
336
335
337
with self .assertWarns (DeprecationWarning ) as w :
336
338
Foo ('test3' ).run ()
337
339
self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
338
340
self .assertIn ('test3' , str (w .warning ))
339
341
self .assertEqual (w .filename , __file__ )
342
+ self .assertIn (f'returned { Nothing .__name__ !r} ' , str (w .warning ))
343
+
344
+ def test_deprecation_of_return_val_from_test_async_method (self ):
345
+ class Foo (unittest .TestCase ):
346
+ async def test1 (self ):
347
+ return 1
348
+
349
+ with self .assertWarns (DeprecationWarning ) as w :
350
+ Foo ('test1' ).run ()
351
+ self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
352
+ self .assertIn ('test1' , str (w .warning ))
353
+ self .assertEqual (w .filename , __file__ )
354
+ self .assertIn ("returned 'coroutine'" , str (w .warning ))
355
+ self .assertIn (
356
+ 'Maybe you forgot to use IsolatedAsyncioTestCase as the base class?' ,
357
+ str (w .warning ),
358
+ )
340
359
341
360
def _check_call_order__subtests (self , result , events , expected_events ):
342
361
class Foo (Test .LoggingTestCase ):
0 commit comments