def test_create_formatted_table(self): output = table.create_table(self.columns, self.rows) self.assertIn("+--------------------------+-------------------------+-------------------------+", output) self.assertIn("|123 |123 |123 |", output) self.assertIn("+==========================+=========================+=========================+", output) self.assertIn("|abc |abc |abc |", output) self.assertIn("+--------------------------+-------------------------+-------------------------+", output)
def to_table(self, style=None): """ Create a table from these params """ columns = ["Name", "Type", "Description"] rows = [item.get_table_row() for item in self.get_params(style)] if len(rows) > 0: return table.create_table(columns, rows) else: return None
def to_rst(self): """ Return the rst representation of this tag and its children. """ trs = self.find('tr') columns = [child.to_rst() for child in trs[0].children] rows = [[child.to_rst() for child in tr.children] for tr in trs[1:]] output = table.create_table(columns,rows) caption_nodes = self.find('caption') if len(caption_nodes) > 0: caption_text = caption_nodes[0].to_rst() output = ".. table:: " + caption_text + "\n\n" + text.indent(output) return output
def to_rst(self): """ Return the rst representation of this tag and its children. """ trs = self.find('tr') columns = [child.to_rst() for child in trs[0].children] rows = [[child.to_rst() for child in tr.children] for tr in trs[1:]] output = table.create_table(columns, rows) caption_nodes = self.find('caption') if len(caption_nodes) > 0: caption_text = caption_nodes[0].to_rst() output = ".. table:: " + caption_text + "\n\n" + text.indent( output) return output
def test_create_formatted_table(self): output = table.create_table(self.columns, self.rows) self.assertIn( "+--------------------------+-------------------------+-------------------------+", output) self.assertIn( "|123 |123 |123 |", output) self.assertIn( "+==========================+=========================+=========================+", output) self.assertIn( "|abc |abc |abc |", output) self.assertIn( "+--------------------------+-------------------------+-------------------------+", output)
def get_responses_table(self, responses): columns = ["Response Code", "Name", "Description"] return table.create_table(columns, responses)