Example #1
0
def test_span_beyond_table_borders(dxf):
    layout = dxf.blocks.new('test_span_beyond_table_borders')
    table = Table((0, 0), 3, 3)
    table.text_cell(0, 2, "ERROR", span=(1, 2))
    with pytest.raises(IndexError):
        table.render(layout)
    table.text_cell(2, 0, "ERROR", span=(2, 1))
    with pytest.raises(IndexError):
        table.render(layout)
Example #2
0
def test_rendering(dxf):
    MockCell.reset()
    layout = dxf.blocks.new('test_rendering')
    table = Table((0, 0), 3, 3)
    indices = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1),
               (2, 2)]
    cell = MockCell(table, 'default', (1, 1))
    for row, col in indices:
        table.set_cell(row, col, cell)
    table.render(layout)
    assert cell.counter == 9  # count get_dxf_entity calls
Example #3
0
def test_dxf_creation_span(dxf):
    MockCell.reset()
    layout = dxf.blocks.new('test_dxf_creation_span')
    table = Table((0, 0), 3, 3)
    indices = [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1),
               (2, 2)]
    cell = MockCell(table, 'default', (1, 1))
    for row, col in indices:
        table.set_cell(row, col, cell)
    spancell = MockCell(table, 'default', span=(2, 2))  # hides 3 cells
    table.set_cell(0, 0, spancell)
    table.render(layout)
    assert cell.counter == 6  # count get_dxf_entity calls