Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_simple_separated_format_with_headers():
"Regression: simple_separated_format() on tables with headers (issue #15)"
from tabulate import simple_separated_format
expected = " a| b\n 1| 2"
formatted = tabulate(
[[1, 2]], headers=["a", "b"], tablefmt=simple_separated_format("|")
)
assert_equal(expected, formatted)
def test_simple_separated_format_signature():
"API: simple_separated_format() type signature is unchanged" ""
assert type(simple_separated_format) is type(lambda: None) # noqa
expected_sig = [("separator", _empty)]
_check_signature(simple_separated_format, expected_sig)
def test_simple_separated_format():
"Regression: simple_separated_format() accepts any separator (issue #12)"
from tabulate import simple_separated_format
fmt = simple_separated_format("!")
expected = "spam!eggs"
formatted = tabulate([["spam", "eggs"]], tablefmt=fmt)
print("expected: %r\n\ngot: %r\n" % (expected, formatted))
assert_equal(expected, formatted)
def test_unaligned_separated():
"Output: non-aligned data columns"
expected = "\n".join(["name|score", "Alice|1", "Bob|333"])
fmt = simple_separated_format("|")
result = tabulate(
[["Alice", 1], ["Bob", 333]],
["name", "score"],
tablefmt=fmt,
stralign=None,
numalign=None,
)
assert_equal(expected, result)
def test_simple_separated_format_signature():
"API: simple_separated_format() type signature is unchanged" ""
assert type(simple_separated_format) is type(lambda: None) # noqa
expected_sig = [("separator", _empty)]
_check_signature(simple_separated_format, expected_sig)