Skip to content

Commit 5a4fe4f

Browse files
authored
CLN: GH29547 format with f-strings (#34502)
1 parent f9b541f commit 5a4fe4f

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

pandas/tests/series/indexing/test_take.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ def test_take():
1616
expected = Series([4, 2, 4], index=[4, 3, 4])
1717
tm.assert_series_equal(actual, expected)
1818

19-
msg = "index {} is out of bounds for( axis 0 with)? size 5"
20-
with pytest.raises(IndexError, match=msg.format(10)):
19+
msg = lambda x: f"index {x} is out of bounds for( axis 0 with)? size 5"
20+
with pytest.raises(IndexError, match=msg(10)):
2121
ser.take([1, 10])
22-
with pytest.raises(IndexError, match=msg.format(5)):
22+
with pytest.raises(IndexError, match=msg(5)):
2323
ser.take([2, 5])
2424

2525

pandas/tests/series/indexing/test_where.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,14 @@ def test_where_setitem_invalid():
222222
# GH 2702
223223
# make sure correct exceptions are raised on invalid list assignment
224224

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+
)
227229
# slice
228230
s = Series(list("abc"))
229231

230-
with pytest.raises(ValueError, match=msg.format("slice")):
232+
with pytest.raises(ValueError, match=msg("slice")):
231233
s[0:3] = list(range(27))
232234

233235
s[0:3] = list(range(3))
@@ -237,7 +239,7 @@ def test_where_setitem_invalid():
237239
# slice with step
238240
s = Series(list("abcdef"))
239241

240-
with pytest.raises(ValueError, match=msg.format("slice")):
242+
with pytest.raises(ValueError, match=msg("slice")):
241243
s[0:4:2] = list(range(27))
242244

243245
s = Series(list("abcdef"))
@@ -248,7 +250,7 @@ def test_where_setitem_invalid():
248250
# neg slices
249251
s = Series(list("abcdef"))
250252

251-
with pytest.raises(ValueError, match=msg.format("slice")):
253+
with pytest.raises(ValueError, match=msg("slice")):
252254
s[:-1] = list(range(27))
253255

254256
s[-3:-1] = list(range(2))
@@ -258,12 +260,12 @@ def test_where_setitem_invalid():
258260
# list
259261
s = Series(list("abc"))
260262

261-
with pytest.raises(ValueError, match=msg.format("list-like")):
263+
with pytest.raises(ValueError, match=msg("list-like")):
262264
s[[0, 1, 2]] = list(range(27))
263265

264266
s = Series(list("abc"))
265267

266-
with pytest.raises(ValueError, match=msg.format("list-like")):
268+
with pytest.raises(ValueError, match=msg("list-like")):
267269
s[[0, 1, 2]] = list(range(2))
268270

269271
# scalar

0 commit comments

Comments
 (0)