Skip to content

Commit

Permalink
gh-128729: Fix ResourceWarning in test_unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jan 11, 2025
1 parent 3a570c6 commit 4e6cb96
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Lib/test/test_unittest/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,12 @@ class Foo(unittest.TestCase):
async def test1(self):
return 1

with self.assertWarns(DeprecationWarning) as w:
Foo('test1').run()
with warnings.catch_warnings():
# Ignore RuntimeWarning: coroutine '...' was never awaited
warnings.simplefilter("ignore", RuntimeWarning)
with self.assertWarns((DeprecationWarning, )) as w:
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))
self.assertEqual(w.filename, __file__)
Expand Down

0 comments on commit 4e6cb96

Please sign in to comment.