gh-117655: Prevent test_strptime from raising a DeprecationWarning (GH-117668)

* Fix `test_strptime` raises a DeprecationWarning
* Ignore deprecation warnings where appropriate.
* Update Lib/test/datetimetester.py

This is follow on work to silence unnecessary warnings from the test suite that changes for https://github.com/python/cpython/issues/70647 added.
This commit is contained in:
Nice Zombies 2024-05-11 23:46:07 +02:00 committed by GitHub
parent cd4cfa6ed2
commit abead548af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 14 deletions

View file

@ -22,6 +22,7 @@ from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
from test import support
from test.support import is_resource_enabled, ALWAYS_EQ, LARGEST, SMALLEST
from test.support import warnings_helper
import datetime as datetime_module
from datetime import MINYEAR, MAXYEAR
@ -2797,6 +2798,7 @@ class TestDateTime(TestDate):
newdate = strptime(string, format)
self.assertEqual(newdate, target, msg=reason)
@warnings_helper.ignore_warnings(category=DeprecationWarning)
def test_strptime_leap_year(self):
# GH-70647: warns if parsing a format with a day and no year.
with self.assertRaises(ValueError):