]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistentl...
authorAlex Waygood <Alex.Waygood@Gmail.com>
Sun, 30 Apr 2023 15:51:46 +0000 (16:51 +0100)
committerGitHub <noreply@github.com>
Sun, 30 Apr 2023 15:51:46 +0000 (15:51 +0000)
Lib/test/test_calendar.py

index 03388e8c55d5a808a18b483c644854b4d6d50856..24e472b5fee8288ec7afca56bc746ca0c6528be8 100644 (file)
@@ -493,11 +493,11 @@ class OutputTestCase(unittest.TestCase):
 class CalendarTestCase(unittest.TestCase):
 
     def test_deprecation_warning(self):
-        with warnings.catch_warnings(record=True) as w:
+        with self.assertWarnsRegex(
+            DeprecationWarning,
+            "The 'January' attribute is deprecated, use 'JANUARY' instead"
+        ):
             calendar.January
-        self.assertEqual(len(w), 1)
-        self.assertEqual(w[0].category, DeprecationWarning)
-        self.assertIn("The 'January' attribute is deprecated, use 'JANUARY' instead", str(w[0].message))
 
     def test_isleap(self):
         # Make sure that the return is right for a few years, and