@@ -222,12 +222,14 @@ def test_where_setitem_invalid():
222
222
# GH 2702
223
223
# make sure correct exceptions are raised on invalid list assignment
224
224
225
- msg = "cannot set using a {} indexer with a different length than the value"
226
-
225
+ msg = (
226
+ lambda x : f"cannot set using a { x } indexer with a "
227
+ "different length than the value"
228
+ )
227
229
# slice
228
230
s = Series (list ("abc" ))
229
231
230
- with pytest .raises (ValueError , match = msg . format ("slice" )):
232
+ with pytest .raises (ValueError , match = msg ("slice" )):
231
233
s [0 :3 ] = list (range (27 ))
232
234
233
235
s [0 :3 ] = list (range (3 ))
@@ -237,7 +239,7 @@ def test_where_setitem_invalid():
237
239
# slice with step
238
240
s = Series (list ("abcdef" ))
239
241
240
- with pytest .raises (ValueError , match = msg . format ("slice" )):
242
+ with pytest .raises (ValueError , match = msg ("slice" )):
241
243
s [0 :4 :2 ] = list (range (27 ))
242
244
243
245
s = Series (list ("abcdef" ))
@@ -248,7 +250,7 @@ def test_where_setitem_invalid():
248
250
# neg slices
249
251
s = Series (list ("abcdef" ))
250
252
251
- with pytest .raises (ValueError , match = msg . format ("slice" )):
253
+ with pytest .raises (ValueError , match = msg ("slice" )):
252
254
s [:- 1 ] = list (range (27 ))
253
255
254
256
s [- 3 :- 1 ] = list (range (2 ))
@@ -258,12 +260,12 @@ def test_where_setitem_invalid():
258
260
# list
259
261
s = Series (list ("abc" ))
260
262
261
- with pytest .raises (ValueError , match = msg . format ("list-like" )):
263
+ with pytest .raises (ValueError , match = msg ("list-like" )):
262
264
s [[0 , 1 , 2 ]] = list (range (27 ))
263
265
264
266
s = Series (list ("abc" ))
265
267
266
- with pytest .raises (ValueError , match = msg . format ("list-like" )):
268
+ with pytest .raises (ValueError , match = msg ("list-like" )):
267
269
s [[0 , 1 , 2 ]] = list (range (2 ))
268
270
269
271
# scalar
0 commit comments