@@ -1890,13 +1890,10 @@ def test_dti_addsub_int(self, tz_naive_fixture, one):
1890
1890
1891
1891
with pytest .raises (TypeError , match = msg ):
1892
1892
rng + one
1893
-
1894
1893
with pytest .raises (TypeError , match = msg ):
1895
1894
rng += one
1896
-
1897
1895
with pytest .raises (TypeError , match = msg ):
1898
1896
rng - one
1899
-
1900
1897
with pytest .raises (TypeError , match = msg ):
1901
1898
rng -= one
1902
1899
@@ -1910,13 +1907,8 @@ def test_dti_add_intarray_tick(self, int_holder, freq):
1910
1907
dti = pd .date_range ("2016-01-01" , periods = 2 , freq = freq )
1911
1908
other = int_holder ([4 , - 1 ])
1912
1909
1913
- msg = "Addition/subtraction of integers"
1914
-
1915
- with pytest .raises (TypeError , match = msg ):
1916
- dti + other
1917
-
1918
- with pytest .raises (TypeError , match = msg ):
1919
- other + dti
1910
+ msg = "Addition/subtraction of integers|cannot subtract DatetimeArray from"
1911
+ assert_invalid_addsub_type (dti , other , msg )
1920
1912
1921
1913
@pytest .mark .parametrize ("freq" , ["W" , "M" , "MS" , "Q" ])
1922
1914
@pytest .mark .parametrize ("int_holder" , [np .array , pd .Index ])
@@ -1925,29 +1917,18 @@ def test_dti_add_intarray_non_tick(self, int_holder, freq):
1925
1917
dti = pd .date_range ("2016-01-01" , periods = 2 , freq = freq )
1926
1918
other = int_holder ([4 , - 1 ])
1927
1919
1928
- msg = "Addition/subtraction of integers"
1929
-
1930
- with pytest .raises (TypeError , match = msg ):
1931
- dti + other
1932
-
1933
- with pytest .raises (TypeError , match = msg ):
1934
- other + dti
1920
+ msg = "Addition/subtraction of integers|cannot subtract DatetimeArray from"
1921
+ assert_invalid_addsub_type (dti , other , msg )
1935
1922
1936
1923
@pytest .mark .parametrize ("int_holder" , [np .array , pd .Index ])
1937
1924
def test_dti_add_intarray_no_freq (self , int_holder ):
1938
1925
# GH#19959
1939
1926
dti = pd .DatetimeIndex (["2016-01-01" , "NaT" , "2017-04-05 06:07:08" ])
1940
1927
other = int_holder ([9 , 4 , - 1 ])
1941
- tmsg = "cannot subtract DatetimeArray from"
1942
- msg = "Addition/subtraction of integers"
1943
- with pytest .raises (TypeError , match = msg ):
1944
- dti + other
1945
- with pytest .raises (TypeError , match = msg ):
1946
- other + dti
1947
- with pytest .raises (TypeError , match = msg ):
1948
- dti - other
1949
- with pytest .raises (TypeError , match = tmsg ):
1950
- other - dti
1928
+ msg = "|" .join (
1929
+ ["cannot subtract DatetimeArray from" , "Addition/subtraction of integers" ]
1930
+ )
1931
+ assert_invalid_addsub_type (dti , other , msg )
1951
1932
1952
1933
# -------------------------------------------------------------
1953
1934
# Binary operations DatetimeIndex and TimedeltaIndex/array
0 commit comments