aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_asyncio/test_events.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_events.py
parentb4e048411f4c62ad7343bca32c307f0bf5ef74b4 (diff)
downloadcpython-090721721b373c50544d297b56c217cf15992cbe.tar.gz
cpython-090721721b373c50544d297b56c217cf15992cbe.zip
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index a30867e2802..05d9107b28e 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2712,12 +2712,12 @@ class GetEventLoopTestsMixin:
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaises(TestError):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
asyncio.set_event_loop(None)
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaises(TestError):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
with self.assertRaisesRegex(RuntimeError, 'no running'):
asyncio.get_running_loop()
@@ -2734,13 +2734,13 @@ class GetEventLoopTestsMixin:
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaises(TestError):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
asyncio.set_event_loop(None)
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaises(TestError):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
finally:
asyncio.set_event_loop_policy(old_policy)
@@ -2762,12 +2762,12 @@ class GetEventLoopTestsMixin:
with self.assertWarns(DeprecationWarning) as cm:
loop2 = asyncio.get_event_loop()
self.addCleanup(loop2.close)
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
asyncio.set_event_loop(None)
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaisesRegex(RuntimeError, 'no current'):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
with self.assertRaisesRegex(RuntimeError, 'no running'):
asyncio.get_running_loop()
@@ -2783,13 +2783,13 @@ class GetEventLoopTestsMixin:
asyncio.set_event_loop(loop)
with self.assertWarns(DeprecationWarning) as cm:
self.assertIs(asyncio.get_event_loop(), loop)
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
asyncio.set_event_loop(None)
with self.assertWarns(DeprecationWarning) as cm:
with self.assertRaisesRegex(RuntimeError, 'no current'):
asyncio.get_event_loop()
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(cm.filename, __file__)
finally:
asyncio.set_event_loop_policy(old_policy)