@@ -2065,7 +2065,10 @@ def test_to_datetime_iso8601_fails(self, input, format, exact):
2065
2065
# `format` is longer than the string, so this fails regardless of `exact`
2066
2066
with pytest .raises (
2067
2067
ValueError ,
2068
- match = rf"time data '{ input } ' does not match format '{ format } '" ,
2068
+ match = (
2069
+ rf"time data '{ input } ' does not match format "
2070
+ rf"\'{ format } \' \((match|search)\) at position 0"
2071
+ ),
2069
2072
):
2070
2073
to_datetime (input , format = format , exact = exact )
2071
2074
@@ -2084,7 +2087,7 @@ def test_to_datetime_iso8601_exact_fails(self, input, format):
2084
2087
# `format` is shorter than the date string, so only fails with `exact=True`
2085
2088
with pytest .raises (
2086
2089
ValueError ,
2087
- match = "unconverted data remains: |does not match format" ,
2090
+ match = "( unconverted data remains: |does not match format).* at position 0 " ,
2088
2091
):
2089
2092
to_datetime (input , format = format )
2090
2093
@@ -2120,7 +2123,10 @@ def test_to_datetime_iso8601_separator(self, input, format):
2120
2123
# https://github.com/pandas-dev/pandas/issues/12649
2121
2124
with pytest .raises (
2122
2125
ValueError ,
2123
- match = rf"time data \'{ input } \' does not match format '{ format } '" ,
2126
+ match = (
2127
+ rf"time data '{ input } ' does not match format "
2128
+ rf"'{ format } ' \(match\) at position 0"
2129
+ ),
2124
2130
):
2125
2131
to_datetime (input , format = format )
2126
2132
@@ -2677,7 +2683,7 @@ def test_day_not_in_month_raise(self, cache):
2677
2683
2678
2684
@pytest .mark .parametrize ("arg" , ["2015-02-29" , "2015-02-32" , "2015-04-31" ])
2679
2685
def test_day_not_in_month_raise_value (self , cache , arg ):
2680
- msg = "day is out of range for month|unconverted data remains"
2686
+ msg = "( day is out of range for month|unconverted data remains).* at position 0 "
2681
2687
with pytest .raises (ValueError , match = msg ):
2682
2688
to_datetime (arg , errors = "raise" , format = "%Y-%m-%d" , cache = cache )
2683
2689
0 commit comments