@@ -277,25 +277,36 @@ async def on_cleanup2(self):
277
277
self .assertEqual (events , ['asyncSetUp' , 'test' , 'asyncTearDown' , 'cleanup2' , 'cleanup1' ])
278
278
279
279
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
281
284
class Test (unittest .IsolatedAsyncioTestCase ):
282
285
async def test1 (self ):
283
286
return 1
284
287
async def test2 (self ):
285
288
yield 1
289
+ async def test3 (self ):
290
+ return Nothing ()
286
291
287
292
with self .assertWarns (DeprecationWarning ) as w :
288
293
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 ))
290
295
self .assertIn ('test1' , str (w .warning ))
291
296
self .assertEqual (w .filename , __file__ )
292
297
293
298
with self .assertWarns (DeprecationWarning ) as w :
294
299
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 ))
296
301
self .assertIn ('test2' , str (w .warning ))
297
302
self .assertEqual (w .filename , __file__ )
298
303
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
+
299
310
def test_cleanups_interleave_order (self ):
300
311
events = []
301
312
0 commit comments