@@ -49,8 +49,7 @@ def test_numpy_ufuncs_basic(index, func):
4949 # https://numpy.org/doc/stable/reference/ufuncs.html
5050
5151 if isinstance (index , DatetimeIndexOpsMixin ):
52- # raise TypeError or ValueError (PeriodIndex)
53- with pytest .raises (Exception ):
52+ with tm .external_error_raised ((TypeError , AttributeError )):
5453 with np .errstate (all = "ignore" ):
5554 func (index )
5655 elif isinstance (index , (Float64Index , Int64Index , UInt64Index )):
@@ -66,7 +65,7 @@ def test_numpy_ufuncs_basic(index, func):
6665 if len (index ) == 0 :
6766 pass
6867 else :
69- with pytest . raises ( Exception ):
68+ with tm . external_error_raised (( TypeError , AttributeError ) ):
7069 with np .errstate (all = "ignore" ):
7170 func (index )
7271
@@ -77,7 +76,6 @@ def test_numpy_ufuncs_basic(index, func):
7776def test_numpy_ufuncs_other (index , func , request ):
7877 # test ufuncs of numpy, see:
7978 # https://numpy.org/doc/stable/reference/ufuncs.html
80-
8179 if isinstance (index , (DatetimeIndex , TimedeltaIndex )):
8280 if isinstance (index , DatetimeIndex ) and index .tz is not None :
8381 if func in [np .isfinite , np .isnan , np .isinf ]:
@@ -96,13 +94,11 @@ def test_numpy_ufuncs_other(index, func, request):
9694 result = func (index )
9795 assert isinstance (result , np .ndarray )
9896 else :
99- # raise TypeError or ValueError (PeriodIndex)
100- with pytest .raises (Exception ):
97+ with tm .external_error_raised (TypeError ):
10198 func (index )
10299
103100 elif isinstance (index , PeriodIndex ):
104- # raise TypeError or ValueError (PeriodIndex)
105- with pytest .raises (Exception ):
101+ with tm .external_error_raised (TypeError ):
106102 func (index )
107103
108104 elif isinstance (index , (Float64Index , Int64Index , UInt64Index )):
@@ -114,5 +110,5 @@ def test_numpy_ufuncs_other(index, func, request):
114110 if len (index ) == 0 :
115111 pass
116112 else :
117- with pytest . raises ( Exception ):
113+ with tm . external_error_raised ( TypeError ):
118114 func (index )
0 commit comments