@@ -2056,7 +2056,10 @@ def test_to_datetime_iso8601_fails(self, input, format, exact):
2056
2056
# `format` is longer than the string, so this fails regardless of `exact`
2057
2057
with pytest .raises (
2058
2058
ValueError ,
2059
- match = rf"time data '{ input } ' does not match format '{ format } '" ,
2059
+ match = (
2060
+ rf"time data '{ input } ' does not match format "
2061
+ rf"\'{ format } \' \((match|search)\) at position 0"
2062
+ ),
2060
2063
):
2061
2064
to_datetime (input , format = format , exact = exact )
2062
2065
@@ -2075,7 +2078,7 @@ def test_to_datetime_iso8601_exact_fails(self, input, format):
2075
2078
# `format` is shorter than the date string, so only fails with `exact=True`
2076
2079
with pytest .raises (
2077
2080
ValueError ,
2078
- match = "unconverted data remains: |does not match format" ,
2081
+ match = "( unconverted data remains: |does not match format).* at position 0 " ,
2079
2082
):
2080
2083
to_datetime (input , format = format )
2081
2084
@@ -2111,7 +2114,10 @@ def test_to_datetime_iso8601_separator(self, input, format):
2111
2114
# https://github.com/pandas-dev/pandas/issues/12649
2112
2115
with pytest .raises (
2113
2116
ValueError ,
2114
- match = rf"time data \'{ input } \' does not match format '{ format } '" ,
2117
+ match = (
2118
+ rf"time data '{ input } ' does not match format "
2119
+ rf"'{ format } ' \(match\) at position 0"
2120
+ ),
2115
2121
):
2116
2122
to_datetime (input , format = format )
2117
2123
@@ -2666,7 +2672,7 @@ def test_day_not_in_month_raise(self, cache):
2666
2672
2667
2673
@pytest .mark .parametrize ("arg" , ["2015-02-29" , "2015-02-32" , "2015-04-31" ])
2668
2674
def test_day_not_in_month_raise_value (self , cache , arg ):
2669
- msg = "day is out of range for month|unconverted data remains"
2675
+ msg = "( day is out of range for month|unconverted data remains).* at position 0 "
2670
2676
with pytest .raises (ValueError , match = msg ):
2671
2677
to_datetime (arg , errors = "raise" , format = "%Y-%m-%d" , cache = cache )
2672
2678
0 commit comments