@@ -72,9 +72,10 @@ def test_nonzero_single_element(self):
72
72
assert not df .bool ()
73
73
74
74
df = DataFrame ([[False , False ]])
75
- with pytest .raises (ValueError ):
75
+ msg = "The truth value of a DataFrame is ambiguous"
76
+ with pytest .raises (ValueError , match = msg ):
76
77
df .bool ()
77
- with pytest .raises (ValueError ):
78
+ with pytest .raises (ValueError , match = msg ):
78
79
bool (df )
79
80
80
81
def test_get_numeric_data_preserve_dtype (self ):
@@ -189,30 +190,31 @@ class TestDataFrame2:
189
190
def test_validate_bool_args (self , value ):
190
191
df = DataFrame ({"a" : [1 , 2 , 3 ], "b" : [4 , 5 , 6 ]})
191
192
192
- with pytest .raises (ValueError ):
193
+ msg = 'For argument "inplace" expected type bool, received type'
194
+ with pytest .raises (ValueError , match = msg ):
193
195
super (DataFrame , df ).rename_axis (
194
196
mapper = {"a" : "x" , "b" : "y" }, axis = 1 , inplace = value
195
197
)
196
198
197
- with pytest .raises (ValueError ):
199
+ with pytest .raises (ValueError , match = msg ):
198
200
super (DataFrame , df ).drop ("a" , axis = 1 , inplace = value )
199
201
200
- with pytest .raises (ValueError ):
202
+ with pytest .raises (ValueError , match = msg ):
201
203
super (DataFrame , df )._consolidate (inplace = value )
202
204
203
- with pytest .raises (ValueError ):
205
+ with pytest .raises (ValueError , match = msg ):
204
206
super (DataFrame , df ).fillna (value = 0 , inplace = value )
205
207
206
- with pytest .raises (ValueError ):
208
+ with pytest .raises (ValueError , match = msg ):
207
209
super (DataFrame , df ).replace (to_replace = 1 , value = 7 , inplace = value )
208
210
209
- with pytest .raises (ValueError ):
211
+ with pytest .raises (ValueError , match = msg ):
210
212
super (DataFrame , df ).interpolate (inplace = value )
211
213
212
- with pytest .raises (ValueError ):
214
+ with pytest .raises (ValueError , match = msg ):
213
215
super (DataFrame , df )._where (cond = df .a > 2 , inplace = value )
214
216
215
- with pytest .raises (ValueError ):
217
+ with pytest .raises (ValueError , match = msg ):
216
218
super (DataFrame , df ).mask (cond = df .a > 2 , inplace = value )
217
219
218
220
def test_unexpected_keyword (self ):
@@ -222,16 +224,17 @@ def test_unexpected_keyword(self):
222
224
ts = df ["joe" ].copy ()
223
225
ts [2 ] = np .nan
224
226
225
- with pytest .raises (TypeError , match = "unexpected keyword" ):
227
+ msg = "unexpected keyword"
228
+ with pytest .raises (TypeError , match = msg ):
226
229
df .drop ("joe" , axis = 1 , in_place = True )
227
230
228
- with pytest .raises (TypeError , match = "unexpected keyword" ):
231
+ with pytest .raises (TypeError , match = msg ):
229
232
df .reindex ([1 , 0 ], inplace = True )
230
233
231
- with pytest .raises (TypeError , match = "unexpected keyword" ):
234
+ with pytest .raises (TypeError , match = msg ):
232
235
ca .fillna (0 , inplace = True )
233
236
234
- with pytest .raises (TypeError , match = "unexpected keyword" ):
237
+ with pytest .raises (TypeError , match = msg ):
235
238
ts .fillna (0 , in_place = True )
236
239
237
240
0 commit comments