File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -102,12 +102,17 @@ def _is_file(f):
102102)
103103
104104
105+ def _is_separating_line_value (value ):
106+ return type (value ) == str and value .strip () is SEPARATING_LINE
107+
108+
105109def _is_separating_line (row ):
106110 row_type = type (row )
107111 is_sl = (row_type == list or row_type == str ) and (
108- (len (row ) >= 1 and row [0 ] is SEPARATING_LINE )
109- or (len (row ) >= 2 and row [1 ] is SEPARATING_LINE )
112+ (len (row ) >= 1 and _is_separating_line_value ( row [0 ]) )
113+ or (len (row ) >= 2 and _is_separating_line_value ( row [1 ]) )
110114 )
115+
111116 return is_sl
112117
113118
Original file line number Diff line number Diff line change @@ -2935,6 +2935,27 @@ def test_list_of_lists_with_index_with_sep_line():
29352935 assert_equal (expected , result )
29362936
29372937
2938+ def test_with_padded_columns_with_sep_line ():
2939+ table = [
2940+ ["1" , "one" ], # "1" as a str on purpose
2941+ [1_000 , "one K" ],
2942+ SEPARATING_LINE ,
2943+ [1_000_000 , "one M" ],
2944+ ]
2945+ expected = "\n " .join (
2946+ [
2947+ "+---------+-------+" ,
2948+ "| 1 | one |" ,
2949+ "| 1000 | one K |" ,
2950+ "|---------+-------|" ,
2951+ "| 1000000 | one M |" ,
2952+ "+---------+-------+" ,
2953+ ]
2954+ )
2955+ result = tabulate (table , tablefmt = "psql" )
2956+ assert_equal (expected , result )
2957+
2958+
29382959def test_list_of_lists_with_supplied_index ():
29392960 "Output: a table with a supplied index"
29402961 dd = zip (* [list (range (3 )), list (range (101 , 104 ))])
You can’t perform that action at this time.
0 commit comments