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):
102
102
)
103
103
104
104
105
+ def _is_separating_line_value (value ):
106
+ return type (value ) == str and value .strip () is SEPARATING_LINE
107
+
108
+
105
109
def _is_separating_line (row ):
106
110
row_type = type (row )
107
111
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 ]) )
110
114
)
115
+
111
116
return is_sl
112
117
113
118
Original file line number Diff line number Diff line change @@ -2935,6 +2935,27 @@ def test_list_of_lists_with_index_with_sep_line():
2935
2935
assert_equal (expected , result )
2936
2936
2937
2937
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
+
2938
2959
def test_list_of_lists_with_supplied_index ():
2939
2960
"Output: a table with a supplied index"
2940
2961
dd = zip (* [list (range (3 )), list (range (101 , 104 ))])
You can’t perform that action at this time.
0 commit comments