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 @@ -101,12 +101,17 @@ def _is_file(f):
101101)
102102
103103
104+ def _is_separating_line_value (value ):
105+ return type (value ) == str and value .strip () == SEPARATING_LINE
106+
107+
104108def _is_separating_line (row ):
105109 row_type = type (row )
106110 is_sl = (row_type == list or row_type == str ) and (
107- (len (row ) >= 1 and row [0 ] == SEPARATING_LINE )
108- or (len (row ) >= 2 and row [1 ] == SEPARATING_LINE )
111+ (len (row ) >= 1 and _is_separating_line_value ( row [0 ]) )
112+ or (len (row ) >= 2 and _is_separating_line_value ( row [1 ]) )
109113 )
114+
110115 return is_sl
111116
112117
Original file line number Diff line number Diff line change @@ -2881,6 +2881,27 @@ def test_list_of_lists_with_index_with_sep_line():
28812881 assert_equal (expected , result )
28822882
28832883
2884+ def test_with_padded_columns_with_sep_line ():
2885+ table = [
2886+ ["1" , "one" ], # "1" as a str on purpose
2887+ [1_000 , "one K" ],
2888+ SEPARATING_LINE ,
2889+ [1_000_000 , "one M" ],
2890+ ]
2891+ expected = "\n " .join (
2892+ [
2893+ "+---------+-------+" ,
2894+ "| 1 | one |" ,
2895+ "| 1000 | one K |" ,
2896+ "|---------+-------|" ,
2897+ "| 1000000 | one M |" ,
2898+ "+---------+-------+" ,
2899+ ]
2900+ )
2901+ result = tabulate (table , tablefmt = "psql" )
2902+ assert_equal (expected , result )
2903+
2904+
28842905def test_list_of_lists_with_supplied_index ():
28852906 "Output: a table with a supplied index"
28862907 dd = zip (* [list (range (3 )), list (range (101 , 104 ))])
You can’t perform that action at this time.
0 commit comments