summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_re.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-04-24 07:23:59 (GMT)
committerGitHub <noreply@github.com>2022-04-24 07:23:59 (GMT)
commit090721721b373c50544d297b56c217cf15992cbe (patch)
treeeac831fb9a94fa4fec902c6dda217c60abfcc38d /Lib/test/test_re.py
parentb4e048411f4c62ad7343bca32c307f0bf5ef74b4 (diff)
downloadcpython-090721721b373c50544d297b56c217cf15992cbe.zip
cpython-090721721b373c50544d297b56c217cf15992cbe.tar.gz
cpython-090721721b373c50544d297b56c217cf15992cbe.tar.bz2
Simplify testing the warning filename (GH-91868)
The context manager result has the "filename" attribute.
Diffstat (limited to 'Lib/test/test_re.py')
-rw-r--r--Lib/test/test_re.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 91971d8..a4c2f1f3 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -2608,11 +2608,11 @@ class ImplementationTest(unittest.TestCase):
for name in deprecated:
with self.subTest(module=name):
sys.modules.pop(name, None)
- with self.assertWarns(DeprecationWarning) as cm:
+ with self.assertWarns(DeprecationWarning) as w:
__import__(name)
- self.assertEqual(str(cm.warnings[0].message),
+ self.assertEqual(str(w.warning),
f"module {name!r} is deprecated")
- self.assertEqual(cm.warnings[0].filename, __file__)
+ self.assertEqual(w.filename, __file__)
self.assertIn(name, sys.modules)
mod = sys.modules[name]
self.assertEqual(mod.__name__, name)