Skip to content

Commit 5f9b029

Browse files
authored
Merge pull request astanin#1 from pzarfos/fix-#214-maxcolwidths-doesn't-accept-tuple
added regression test for maxcolwidths doesn't accept tuple issue
2 parents fbdb1fd + b50e9ce commit 5f9b029

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_regression.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,27 @@ def test_preserve_line_breaks_with_maxcolwidths():
488488
assert_equal(expected, result)
489489

490490

491+
def test_maxcolwidths_accepts_list_or_tuple():
492+
"Regression: maxcolwidths can accept a list or a tuple (github issue #214)"
493+
table = [["lorem ipsum dolor sit amet"]*3]
494+
expected = "\n".join(
495+
[
496+
"+-------------+----------+----------------------------+",
497+
"| lorem ipsum | lorem | lorem ipsum dolor sit amet |",
498+
"| dolor sit | ipsum | |",
499+
"| amet | dolor | |",
500+
"| | sit amet | |",
501+
"+-------------+----------+----------------------------+",
502+
]
503+
)
504+
# test with maxcolwidths as a list
505+
result = tabulate(table, tablefmt="grid", maxcolwidths=[12, 8])
506+
assert_equal(expected, result)
507+
# test with maxcolwidths as a tuple
508+
result = tabulate(table, tablefmt="grid", maxcolwidths=(12, 8))
509+
assert_equal(expected, result)
510+
511+
491512
def test_exception_on_empty_data_with_maxcolwidths():
492513
"Regression: exception on empty data when using maxcolwidths (github issue #180)"
493514
result = tabulate([], maxcolwidths=5)

0 commit comments

Comments
 (0)