Moar tests

This commit is contained in:
Julien Palard 2018-10-23 18:40:30 +02:00
parent 83703c6a5e
commit d527497b1f

View File

@ -12,7 +12,7 @@
import pytest import pytest
from docutils.utils import column_width from docutils.utils import column_width
from sphinx.writers.text import MAXWIDTH from sphinx.writers.text import MAXWIDTH, Table, Cell
def with_text_app(*args, **kw): def with_text_app(*args, **kw):
@ -87,6 +87,41 @@ def test_nonascii_maxwidth(app, status, warning):
assert max(line_widths) < MAXWIDTH assert max(line_widths) < MAXWIDTH
def test_table_builder():
table = Table([6, 6])
table.add_cell(Cell("foo"))
table.add_cell(Cell("bar"))
table_str = str(table).split("\n")
assert table_str[0] == "+--------+--------+"
assert table_str[1] == "| foo | bar |"
assert table_str[2] == "+--------+--------+"
assert repr(table).count("<Cell ") == 2
def test_table_separator():
table = Table([6, 6])
table.add_cell(Cell("foo"))
table.add_cell(Cell("bar"))
table.set_separator()
table.add_row()
table.add_cell(Cell("FOO"))
table.add_cell(Cell("BAR"))
table_str = str(table).split("\n")
assert table_str[0] == "+--------+--------+"
assert table_str[1] == "| foo | bar |"
assert table_str[2] == "|========|========|"
assert table_str[3] == "| FOO | BAR |"
assert table_str[4] == "+--------+--------+"
assert repr(table).count("<Cell ") == 4
def test_table_cell():
cell = Cell("Foo bar baz")
cell.wrap(3)
assert "Cell" in repr(cell)
assert cell.wrapped == ["Foo", "bar", "baz"]
@with_text_app() @with_text_app()
def test_table_with_empty_cell(app, status, warning): def test_table_with_empty_cell(app, status, warning):
app.builder.build_update() app.builder.build_update()