File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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+
491512def test_exception_on_empty_data_with_maxcolwidths ():
492513 "Regression: exception on empty data when using maxcolwidths (github issue #180)"
493514 result = tabulate ([], maxcolwidths = 5 )
You can’t perform that action at this time.
0 commit comments