diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2022-04-24 10:23:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-24 10:23:59 +0300 |
commit | 090721721b373c50544d297b56c217cf15992cbe (patch) | |
tree | eac831fb9a94fa4fec902c6dda217c60abfcc38d /Lib/test/test_asyncio/test_events.py | |
parent | b4e048411f4c62ad7343bca32c307f0bf5ef74b4 (diff) | |
download | cpython-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.py | 16 |
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) |