summaryrefslogtreecommitdiff
path: root/Lib/test/test_asyncio/test_futures.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-24 10:23:59 +0300
committerGitHub <noreply@github.com>2022-04-24 10:23:59 +0300
commit090721721b373c50544d297b56c217cf15992cbe (patch)
treeeac831fb9a94fa4fec902c6dda217c60abfcc38d /Lib/test/test_asyncio/test_futures.py
parentb4e048411f4c62ad7343bca32c307f0bf5ef74b4 (diff)
downloadcpython-git-090721721b373c50544d297b56c217cf15992cbe.tar.gz
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
Diffstat (limited to 'Lib/test/test_asyncio/test_futures.py')
-rw-r--r--Lib/test/test_asyncio/test_futures.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_asyncio/test_futures.py b/Lib/test/test_asyncio/test_futures.py
index cf677f6a95..f4a46ec90a 100644
--- a/Lib/test/test_asyncio/test_futures.py
+++ b/Lib/test/test_asyncio/test_futures.py
@@ -148,7 +148,7 @@ class BaseFutureTests:
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaisesRegex(RuntimeError, 'There is no current event loop'):
self._new_future()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
def test_constructor_use_running_loop(self):
async def test():
@@ -163,7 +163,7 @@ class BaseFutureTests:
self.addCleanup(asyncio.set_event_loop, None)
with self.assertWarns(DeprecationWarning) as cm:
f = self._new_future()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
self.assertIs(f._loop, self.loop)
self.assertIs(f.get_loop(), self.loop)
@@ -510,7 +510,7 @@ class BaseFutureTests:
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaises(RuntimeError):
asyncio.wrap_future(f1)
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
ex.shutdown(wait=True)
def test_wrap_future_use_running_loop(self):
@@ -534,7 +534,7 @@ class BaseFutureTests:
f1 = ex.submit(run, 'oi')
with self.assertWarns(DeprecationWarning) as cm:
f2 = asyncio.wrap_future(f1)
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
self.assertIs(self.loop, f2._loop)
ex.shutdown(wait=True)