Fix trailing None/empty cell silently dropped in plain-format rows by gaoflow · Pull Request #433 · astanin/python-tabulate · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions tabulate/__init__.py
10 changes: 5 additions & 5 deletions test/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_list_of_lists():
" string number",
"-- -------- --------",
"a one 1",
"b two",
"b two ",
]
)
result = tabulate(ll, headers=["string", "number"])
Expand All @@ -72,7 +72,7 @@ def test_list_of_lists_firstrow():
" string number",
"-- -------- --------",
"a one 1",
"b two",
"b two ",
]
)
result = tabulate(ll, headers="firstrow")
Expand All @@ -82,7 +82,7 @@ def test_list_of_lists_firstrow():
def test_list_of_lists_keys():
"Input: a list of lists with column indices as headers."
ll = [["a", "one", 1], ["b", "two", None]]
expected = "\n".join(["0 1 2", "--- --- ---", "a one 1", "b two"])
expected = "\n".join(["0 1 2", "--- --- ---", "a one 1", "b two "])
result = tabulate(ll, headers="keys")
assert_equal(expected, result)

Expand Down Expand Up @@ -405,8 +405,8 @@ def test_list_of_dicts_with_missing_keys():
[
" foo bar baz",
"----- ----- -----",
" 1",
" 2",
" 1 ",
" 2 ",
" 4 3",
]
)
Expand Down
4 changes: 2 additions & 2 deletions test/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -3028,7 +3028,7 @@ def test_missingval_multi():
missingval=("n/a", "?"),
tablefmt="plain",
)
expected = "Alice Bob Charlie\nn/a ?"
expected = "Alice Bob Charlie\nn/a ? "
assert_equal(expected, result)


Expand All @@ -3053,7 +3053,7 @@ def test_column_emptymissing_deduction():
? 1.2342 1/3
0.056789 12,345 abc
?
3,333.3 ?
3,333.3 ?
------------ ----------- ---"""
assert_equal(expected, result)

Expand Down
4 changes: 2 additions & 2 deletions test/test_regression.py