Beispiel #1
0
 def runTest(self):
     # ARRANGE #
     root = Element('root')
     table = Table(TableFormat(first_row_is_header=True), [
         [text_cell('ignored'), text_cell('ignored')],
         [text_cell('ignored'), text_cell('ignored')],
     ])
     # ACT #
     ret_val = sut.render(ConstantPRenderer('para text'), root, table)
     # ASSERT #
     xml_string = as_unicode_str(root)
     self.assertEqual(
         '<root>'
         '<table>'
         '<tr>'
         '<th>para text</th>'
         '<th>para text</th>'
         '</tr>'
         '<tr>'
         '<td>para text</td>'
         '<td>para text</td>'
         '</tr>'
         '</table>'
         '</root>', xml_string)
     self.assertIs(list(root)[0], ret_val)
Beispiel #2
0
 def test_visit_table(self):
     # ARRANGE #
     item = Table(TableFormat('column separator'), [])
     visitor = AVisitorThatRecordsVisitedMethods()
     # ACT #
     ret_val = visitor.visit(item)
     # ASSERT #
     self.assertEqual([Table], visitor.visited_types)
     self.assertIs(item, ret_val)
Beispiel #3
0
 def test_single_empty_row(self):
     # ARRANGE #
     root = Element('root')
     table = Table(TableFormat(), [[]])
     # ACT #
     ret_val = sut.render(ConstantPRenderer('para text'), root, table)
     # ASSERT #
     xml_string = as_unicode_str(root)
     self.assertEqual('<root />', xml_string)
     self.assertIs(root, ret_val)
Beispiel #4
0
def single_text_cell_table(
        single_text_cell_rows: List[List[StrOrText]]) -> Table:
    return Table(TableFormat(), [[text_cell(raw_cell) for raw_cell in row]
                                 for row in single_text_cell_rows])