with pytest.raises(MismatchedRowLengthsException) as error:
TableBuilder(
table_specifications["title"],
table_specifications["widths"],
table_specifications["header_rows"],
table_specifications["headers"],
table_specifications["indent"],
) assert (
str(error.value)
== "Number of table headers must match number of column widths."
)
def test_table_builder_add_row_too_long(): from perfdocs.doc_helpers import MismatchedRowLengthsException, TableBuilder
table = TableBuilder(
table_specifications["title"],
table_specifications["widths"],
table_specifications["header_rows"],
table_specifications["headers"],
table_specifications["indent"],
) with pytest.raises(MismatchedRowLengthsException) as error:
table.add_row(
["big ones", "small ones", "some as big as your head!", "(and bigger)"]
) assert (
str(error.value)
== "Number of items in a row must must number of columns defined."
)
def test_table_builder_add_rows_type_error(): from perfdocs.doc_helpers import TableBuilder
table = TableBuilder(
table_specifications["title"],
table_specifications["widths"],
table_specifications["header_rows"],
table_specifications["headers"],
table_specifications["indent"],
) with pytest.raises(TypeError) as error:
table.add_rows(
["big ones", "small ones", "some as big as your head!", "(and bigger)"]
) assert str(error.value) == "add_rows() requires a two-dimensional list of strings."
def test_table_builder_validate(): from perfdocs.doc_helpers import TableBuilder
table = TableBuilder(
table_specifications["title"],
table_specifications["widths"],
table_specifications["header_rows"],
table_specifications["headers"],
table_specifications["indent"],
)
table.add_row(["big ones", "small ones", "some as big as your head!"])
table.add_row(
["Give 'em a twist", "A flick of the wrist", "That's what the showman said!"]
)
table = table.finish_table()
print(table) assert (
table == " .. list-table:: **I've got a lovely bunch of coconuts**\n" " :widths: 10 10 10\n :header-rows: 1\n\n" " * - **Coconut 1**\n - Coconut 2\n - Coconut 3\n" " * - **big ones**\n - small ones\n - some as big as your head!\n" " * - **Give 'em a twist**\n - A flick of the wrist\n" " - That's what the showman said!\n\n"
)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.