def test_custom_tablefmt():
"Regression: allow custom TableFormat that specifies with_header_hide (github issue #20)"
tablefmt = TableFormat(
lineabove=Line("", "-", " ", ""),
linebelowheader=Line("", "-", " ", ""),
linebetweenrows=None,
linebelow=Line("", "-", " ", ""),
headerrow=DataRow("", " ", ""),
datarow=DataRow("", " ", ""),
padding=0,
with_header_hide=["lineabove", "linebelow"],
)
rows = [["foo", "bar"], ["baz", "qux"]]
expected = "\n".join(["A B", "--- ---", "foo bar", "baz qux"])
result = tabulate(rows, headers=["A", "B"], tablefmt=tablefmt)
assert_equal(result, expected)
def _addCustomTabulateTables():
"""Create a custom ARMI tables within tabulate."""
tabulate._table_formats["armi"] = tabulate.TableFormat(
lineabove=tabulate.Line("", "-", " ", ""),
linebelowheader=tabulate.Line("", "-", " ", ""),
linebetweenrows=None,
linebelow=tabulate.Line("", "-", " ", ""),
headerrow=tabulate.DataRow("", " ", ""),
datarow=tabulate.DataRow("", " ", ""),
padding=0,
with_header_hide=None,
)
tabulate.tabulate_formats = list(sorted(tabulate._table_formats.keys()))
tabulate.multiline_formats["armi"] = "armi"
# runLog makes tables, so make sure this is setup before we initialize the runLog