@@ -240,7 +240,36 @@ def test_invalid_empty_but_required_fields(self):
240240 )
241241
242242 def test_invalid_day_for_month (self ):
243- if platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
243+ if platform .python_implementation () == 'CPython' and sys .version_info >= (3 , 14 ):
244+ for non_leap_year in (1700 , 1800 , 1900 , 2014 ):
245+ self .assertRaisesRegex (
246+ ValueError ,
247+ rf"day 29 must be in range 1..28 for month 2 in year { non_leap_year } " ,
248+ parse_datetime ,
249+ "{}-02-29" .format (non_leap_year ),
250+ )
251+
252+ self .assertRaisesRegex (
253+ ValueError ,
254+ r"day 32 must be in range 1..31 for month 1 in year 2014" ,
255+ parse_datetime ,
256+ "2014-01-32" ,
257+ )
258+
259+ self .assertRaisesRegex (
260+ ValueError ,
261+ r"day 31 must be in range 1..30 for month 6 in year 2014" ,
262+ parse_datetime ,
263+ "2014-06-31" ,
264+ )
265+
266+ self .assertRaisesRegex (
267+ ValueError ,
268+ r"day 0 must be in range 1..28 for month 2 in year 2014" ,
269+ parse_datetime ,
270+ "2014-06-00" ,
271+ )
272+ elif platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
244273 for non_leap_year in (1700 , 1800 , 1900 , 2014 ):
245274 self .assertRaisesRegex (
246275 ValueError ,
@@ -577,7 +606,14 @@ def test_issue_13(self):
577606 )
578607
579608 def test_issue_22 (self ):
580- if platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
609+ if platform .python_implementation () == 'CPython' and sys .version_info >= (3 , 14 ):
610+ self .assertRaisesRegex (
611+ ValueError ,
612+ r"day 31 must be in range 1..30 for month 11 in year 2016" ,
613+ parse_datetime ,
614+ "2016-11-31T12:34:34.521059" ,
615+ )
616+ elif platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
581617 self .assertRaisesRegex (
582618 ValueError ,
583619 r"('day must be in 1..30', 31)" ,
@@ -601,7 +637,14 @@ def test_issue_35(self):
601637 )
602638
603639 def test_issue_42 (self ):
604- if platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
640+ if platform .python_implementation () == 'CPython' and sys .version_info >= (3 , 14 ):
641+ self .assertRaisesRegex (
642+ ValueError ,
643+ r"day 0 must be in range 1..28 for month 2 in year 2014" ,
644+ parse_datetime ,
645+ "20140200" ,
646+ )
647+ elif platform .python_implementation () == 'PyPy' and sys .version_info .major >= 3 :
605648 self .assertRaisesRegex (
606649 ValueError ,
607650 r"('day must be in 1..28', 0)" ,
0 commit comments