Skip to content

Commit 2b66e2f

Browse files
committed
TST: parametrize number of header cols
1 parent e260f58 commit 2b66e2f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

pandas/tests/io/formats/test_to_latex.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,12 +204,25 @@ def test_to_latex_specified_header_without_index(self):
204204
)
205205
assert result == expected
206206

207-
def test_to_latex_number_of_items_in_header_missmatch_raises(self):
207+
@pytest.mark.parametrize(
208+
"header, num_aliases",
209+
[
210+
(["A"], 1),
211+
(("B",), 1),
212+
(("Col1", "Col2", "Col3"), 3),
213+
(("Col1", "Col2", "Col3", "Col4"), 4),
214+
],
215+
)
216+
def test_to_latex_number_of_items_in_header_missmatch_raises(
217+
self,
218+
header,
219+
num_aliases,
220+
):
208221
# GH 7124
209222
df = DataFrame({"a": [1, 2], "b": ["b1", "b2"]})
210-
msg = "Writing 2 cols but got 1 aliases"
223+
msg = f"Writing 2 cols but got {num_aliases} aliases"
211224
with pytest.raises(ValueError, match=msg):
212-
df.to_latex(header=["A"])
225+
df.to_latex(header=header)
213226

214227
def test_to_latex_decimal(self):
215228
# GH 12031

0 commit comments

Comments
 (0)