From d9674180014d26355c32affe2067304d609dafcf Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 11 Jan 2025 17:37:04 +0200 Subject: [PATCH] Simplify the fix. --- Lib/test/test_unittest/test_case.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_unittest/test_case.py b/Lib/test/test_unittest/test_case.py index 1e1599d1d0457e..621f8269a177ce 100644 --- a/Lib/test/test_unittest/test_case.py +++ b/Lib/test/test_unittest/test_case.py @@ -346,11 +346,10 @@ class Foo(unittest.TestCase): async def test1(self): return 1 - with warnings.catch_warnings(): - # Ignore RuntimeWarning: coroutine '...' was never awaited - warnings.simplefilter("ignore", RuntimeWarning) - with self.assertWarns((DeprecationWarning, )) as w: - Foo('test1').run() + with self.assertWarns(DeprecationWarning) as w: + warnings.filterwarnings('ignore', + 'coroutine .* was never awaited', RuntimeWarning) + Foo('test1').run() support.gc_collect() self.assertIn('It is deprecated to return a value that is not None', str(w.warning)) self.assertIn('test1', str(w.warning))