Skip to content

Commit 81ebb9b

Browse files
committed
Remove .replace() and use implicit str concatenation instead
1 parent 098c604 commit 81ebb9b

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

pandas/tests/io/test_clipboard.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -260,26 +260,29 @@ def test_infer_excel_with_nulls(self, request, mock_clipboard):
260260
"multiindex",
261261
[
262262
(
263-
"""\t\t\tcol1\tcol2
264-
A\t0\tTrue\t1\tred
265-
A\t1\tTrue\t\tblue
266-
B\t0\tFalse\t2\tgreen""",
263+
( # Can't use `dedent` here as it will remove the leading `\t`
264+
"\t\t\tcol1\tcol2\n"
265+
"A\t0\tTrue\t1\tred\n"
266+
"A\t1\tTrue\t\tblue\n"
267+
"B\t0\tFalse\t2\tgreen\n"
268+
),
267269
[["A", "A", "B"], [0, 1, 0], [True, True, False]],
268270
),
269271
(
270-
"""\t\tcol1\tcol2
271-
A\t0\t1\tred
272-
A\t1\t\tblue
273-
B\t0\t2\tgreen""",
272+
(
273+
"\t\tcol1\tcol2\n"
274+
"A\t0\t1\tred\n"
275+
"A\t1\t\tblue\n"
276+
"B\t0\t2\tgreen\n"
277+
),
274278
[["A", "A", "B"], [0, 1, 0]],
275279
),
276280
],
277281
)
278282
def test_infer_excel_with_multiindex(self, request, mock_clipboard, multiindex):
279283
# GH41108
280284

281-
# the `.replace()` is because `.dedent()` does not like the leading `\t`
282-
mock_clipboard[request.node.name] = multiindex[0].replace(" ", "")
285+
mock_clipboard[request.node.name] = multiindex[0]
283286
df = read_clipboard()
284287
df_expected = DataFrame(
285288
data={"col1": [1, None, 2], "col2": ["red", "blue", "green"]},

0 commit comments

Comments
 (0)