2222 iNaT ,
2323 parsing ,
2424)
25+ from pandas .compat import PY314
2526from pandas .errors import (
2627 OutOfBoundsDatetime ,
2728 OutOfBoundsTimedelta ,
5758 r"alongside this."
5859)
5960
61+ if PY314 :
62+ NOT_99 = ", not 99"
63+ DAY_IS_OUT_OF_RANGE = (
64+ r"day \d{1,2} must be in range 1\.\.\d{1,2} for month \d{1,2} in year \d{4}"
65+ ", at position 0"
66+ )
67+ else :
68+ NOT_99 = ""
69+ DAY_IS_OUT_OF_RANGE = "day is out of range for month, at position 0"
70+
71+
6072pytestmark = pytest .mark .filterwarnings (
6173 "ignore:errors='ignore' is deprecated:FutureWarning"
6274)
@@ -1451,7 +1463,7 @@ def test_datetime_invalid_scalar(self, value, format):
14511463 r'^Given date string "a" not likely a datetime, at position 0$' ,
14521464 r'^unconverted data remains when parsing with format "%H:%M:%S": "9", '
14531465 f"at position 0. { PARSING_ERR_MSG } $" ,
1454- r "^second must be in 0..59: 00:01:99, at position 0$" ,
1466+ rf "^second must be in 0..59{ NOT_99 } : 00:01:99, at position 0$" ,
14551467 ]
14561468 )
14571469 with pytest .raises (ValueError , match = msg ):
@@ -1509,7 +1521,7 @@ def test_datetime_invalid_index(self, values, format):
15091521 f"{ PARSING_ERR_MSG } $" ,
15101522 r'^unconverted data remains when parsing with format "%H:%M:%S": "9", '
15111523 f"at position 0. { PARSING_ERR_MSG } $" ,
1512- r "^second must be in 0..59: 00:01:99, at position 0$" ,
1524+ rf "^second must be in 0..59{ NOT_99 } : 00:01:99, at position 0$" ,
15131525 ]
15141526 )
15151527 with pytest .raises (ValueError , match = msg ):
@@ -3012,7 +3024,10 @@ def test_day_not_in_month_coerce(self, cache, arg, format):
30123024 assert isna (to_datetime (arg , errors = "coerce" , format = format , cache = cache ))
30133025
30143026 def test_day_not_in_month_raise (self , cache ):
3015- msg = "day is out of range for month: 2015-02-29, at position 0"
3027+ if PY314 :
3028+ msg = "day 29 must be in range 1..28 for month 2 in year 2015: 2015-02-29"
3029+ else :
3030+ msg = "day is out of range for month: 2015-02-29"
30163031 with pytest .raises (ValueError , match = msg ):
30173032 to_datetime ("2015-02-29" , errors = "raise" , cache = cache )
30183033
@@ -3022,12 +3037,12 @@ def test_day_not_in_month_raise(self, cache):
30223037 (
30233038 "2015-02-29" ,
30243039 "%Y-%m-%d" ,
3025- f"^day is out of range for month, at position 0 . { PARSING_ERR_MSG } $" ,
3040+ f"^{ DAY_IS_OUT_OF_RANGE } . { PARSING_ERR_MSG } $" ,
30263041 ),
30273042 (
30283043 "2015-29-02" ,
30293044 "%Y-%d-%m" ,
3030- f"^day is out of range for month, at position 0 . { PARSING_ERR_MSG } $" ,
3045+ f"^{ DAY_IS_OUT_OF_RANGE } . { PARSING_ERR_MSG } $" ,
30313046 ),
30323047 (
30333048 "2015-02-32" ,
@@ -3044,12 +3059,12 @@ def test_day_not_in_month_raise(self, cache):
30443059 (
30453060 "2015-04-31" ,
30463061 "%Y-%m-%d" ,
3047- f"^day is out of range for month, at position 0 . { PARSING_ERR_MSG } $" ,
3062+ f"^{ DAY_IS_OUT_OF_RANGE } . { PARSING_ERR_MSG } $" ,
30483063 ),
30493064 (
30503065 "2015-31-04" ,
30513066 "%Y-%d-%m" ,
3052- f"^day is out of range for month, at position 0 . { PARSING_ERR_MSG } $" ,
3067+ f"^{ DAY_IS_OUT_OF_RANGE } . { PARSING_ERR_MSG } $" ,
30533068 ),
30543069 ],
30553070 )
0 commit comments