@@ -121,23 +121,25 @@ def test_logical_operators_int_dtype_with_float(self):
121
121
# GH#9016: support bitwise op for integer types
122
122
s_0123 = Series (range (4 ), dtype = "int64" )
123
123
124
- with pytest .raises (TypeError ):
124
+ msg = "Cannot perform.+with a dtyped.+array and scalar of type"
125
+ with pytest .raises (TypeError , match = msg ):
125
126
s_0123 & np .NaN
126
- with pytest .raises (TypeError ):
127
+ with pytest .raises (TypeError , match = msg ):
127
128
s_0123 & 3.14
128
- with pytest .raises (TypeError ):
129
+ msg = "unsupported operand type.+for &:"
130
+ with pytest .raises (TypeError , match = msg ):
129
131
s_0123 & [0.1 , 4 , 3.14 , 2 ]
130
- with pytest .raises (TypeError ):
132
+ with pytest .raises (TypeError , match = msg ):
131
133
s_0123 & np .array ([0.1 , 4 , 3.14 , 2 ])
132
- with pytest .raises (TypeError ):
134
+ with pytest .raises (TypeError , match = msg ):
133
135
s_0123 & Series ([0.1 , 4 , - 3.14 , 2 ])
134
136
135
137
def test_logical_operators_int_dtype_with_str (self ):
136
138
s_1111 = Series ([1 ] * 4 , dtype = "int8" )
137
-
138
- with pytest .raises (TypeError ):
139
+ msg = "Cannot perform 'and_' with a dtyped.+array and scalar of type"
140
+ with pytest .raises (TypeError , match = msg ):
139
141
s_1111 & "a"
140
- with pytest .raises (TypeError ):
142
+ with pytest .raises (TypeError , match = "unsupported operand.+for &" ):
141
143
s_1111 & ["a" , "b" , "c" , "d" ]
142
144
143
145
def test_logical_operators_int_dtype_with_bool (self ):
@@ -255,7 +257,8 @@ def test_logical_operators_int_dtype_with_bool_dtype_and_reindex(self):
255
257
def test_scalar_na_logical_ops_corners (self ):
256
258
s = Series ([2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ])
257
259
258
- with pytest .raises (TypeError ):
260
+ msg = "Cannot perform.+with a dtyped.+array and scalar of type"
261
+ with pytest .raises (TypeError , match = msg ):
259
262
s & datetime (2005 , 1 , 1 )
260
263
261
264
s = Series ([2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , datetime (2005 , 1 , 1 )])
@@ -451,8 +454,9 @@ def test_logical_ops_label_based(self):
451
454
expected = Series ([True , True , True ], index = index )
452
455
tm .assert_series_equal (result , expected )
453
456
457
+ msg = "Cannot perform.+with a dtyped.+array and scalar of type"
454
458
for v in [np .nan , "foo" ]:
455
- with pytest .raises (TypeError ):
459
+ with pytest .raises (TypeError , match = msg ):
456
460
t | v
457
461
458
462
for v in [False , 0 ]:
@@ -469,8 +473,9 @@ def test_logical_ops_label_based(self):
469
473
result = Series ([True , False , True ], index = index ) & v
470
474
expected = Series ([False , False , False ], index = index )
471
475
tm .assert_series_equal (result , expected )
476
+ msg = "Cannot perform.+with a dtyped.+array and scalar of type"
472
477
for v in [np .nan ]:
473
- with pytest .raises (TypeError ):
478
+ with pytest .raises (TypeError , match = msg ):
474
479
t & v
475
480
476
481
def test_logical_ops_df_compat (self ):
0 commit comments