@@ -2065,7 +2065,10 @@ def test_to_datetime_iso8601_fails(self, input, format, exact):
20652065 # `format` is longer than the string, so this fails regardless of `exact`
20662066 with pytest .raises (
20672067 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+ ),
20692072 ):
20702073 to_datetime (input , format = format , exact = exact )
20712074
@@ -2084,7 +2087,7 @@ def test_to_datetime_iso8601_exact_fails(self, input, format):
20842087 # `format` is shorter than the date string, so only fails with `exact=True`
20852088 with pytest .raises (
20862089 ValueError ,
2087- match = "unconverted data remains: |does not match format" ,
2090+ match = "( unconverted data remains: |does not match format).* at position 0 " ,
20882091 ):
20892092 to_datetime (input , format = format )
20902093
@@ -2120,7 +2123,10 @@ def test_to_datetime_iso8601_separator(self, input, format):
21202123 # https://github.com/pandas-dev/pandas/issues/12649
21212124 with pytest .raises (
21222125 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+ ),
21242130 ):
21252131 to_datetime (input , format = format )
21262132
@@ -2677,7 +2683,7 @@ def test_day_not_in_month_raise(self, cache):
26772683
26782684 @pytest .mark .parametrize ("arg" , ["2015-02-29" , "2015-02-32" , "2015-04-31" ])
26792685 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 "
26812687 with pytest .raises (ValueError , match = msg ):
26822688 to_datetime (arg , errors = "raise" , format = "%Y-%m-%d" , cache = cache )
26832689
0 commit comments