@@ -277,25 +277,36 @@ async def on_cleanup2(self):
277277 self .assertEqual (events , ['asyncSetUp' , 'test' , 'asyncTearDown' , 'cleanup2' , 'cleanup1' ])
278278
279279 def test_deprecation_of_return_val_from_test (self ):
280- # Issue 41322 - deprecate return of value!=None from a test
280+ # Issue 41322 - deprecate return of value that is not None from a test
281+ class Nothing :
282+ def __eq__ (self , o ):
283+ return o is None
281284 class Test (unittest .IsolatedAsyncioTestCase ):
282285 async def test1 (self ):
283286 return 1
284287 async def test2 (self ):
285288 yield 1
289+ async def test3 (self ):
290+ return Nothing ()
286291
287292 with self .assertWarns (DeprecationWarning ) as w :
288293 Test ('test1' ).run ()
289- self .assertIn ('It is deprecated to return a value!= None' , str (w .warning ))
294+ self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
290295 self .assertIn ('test1' , str (w .warning ))
291296 self .assertEqual (w .filename , __file__ )
292297
293298 with self .assertWarns (DeprecationWarning ) as w :
294299 Test ('test2' ).run ()
295- self .assertIn ('It is deprecated to return a value!= None' , str (w .warning ))
300+ self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
296301 self .assertIn ('test2' , str (w .warning ))
297302 self .assertEqual (w .filename , __file__ )
298303
304+ with self .assertWarns (DeprecationWarning ) as w :
305+ Test ('test3' ).run ()
306+ self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
307+ self .assertIn ('test3' , str (w .warning ))
308+ self .assertEqual (w .filename , __file__ )
309+
299310 def test_cleanups_interleave_order (self ):
300311 events = []
301312
0 commit comments