Пример #1
0
    def validate_test_condition(self, source):
        data = [[1, '', 3, 'hidden'], [None, '2.1', 3.1, 'h'],
                [1.12, 'very long cell', 3.12, 'h2'],
                [1, 'very long cell to be clipped', 3, '']]
        result_file = self.get_data_path('_live_table',
                                         self.BASENAME + '.' + source)
        expected_file = self.get_data_path('expected',
                                           self.BASENAME + '_%s.' + source)
        table = SeabornTable(data[:1],
                             row_columns=['A', 'B', 'C', 'Hidden'],
                             live_tables=[
                                 dict(file_path=result_file,
                                      min_widths=2,
                                      max_widths={
                                          'A': 10,
                                          'B': 10,
                                          'C': 10
                                      },
                                      clip_widths=14,
                                      recreate=True),
                             ])
        self.assert_result_file(expected_file % 0, result_file)
        table.append(data[1])
        self.assert_result_file(expected_file % 1, result_file)
        for index, row in enumerate(data[2:], start=2):
            table.append(
                {col: row[i]
                 for i, col in enumerate(table.row_columns)})
            self.assert_result_file(expected_file % index, result_file)

        table.close_live_table()
        self.assert_result_file(expected_file % (index + 1), result_file)
        self.remove_file(result_file)
Пример #2
0
 def validate_test_condition(self, source):
     data = [['cell 1, 1.0\ncell 1, 1.1', 'cell 1, 2', 'cell 1, 3'],
             [
                 'cell 2, 1', 'cell 2, 2.0\ncell 2, 2.1\ncell 2, 2.2',
                 'cell 2, 3'
             ],
             [
                 'cell 3, 1', '\ncell 3, 2',
                 'cell 3, 3.0\ncell 3, 3.1\ncell 3, 3.2\ncell 3, 3.3'
             ],
             [
                 'cell 4, 1.0\n               cell 4, 1.1',
                 'cell 4, 2.0\ncell 4, 2.1',
                 'cell 4, 3.0\ncell 4, 3.1\ncell 4, 3.2'
             ], ['\n\ncell 5, 1', 'cell 5, 2', 'cell 5, 3']]
     table = SeabornTable(
         data,
         row_columns=['Header 1', 'Header 2.0\nHeader 2.1', 'Header 3'])
     basename = self.BASENAME % source
     expected_file = self.get_data_path('expected', basename)
     result_file = self.get_data_path('_shared', basename)
     table.obj_to_file(result_file, break_line=True)
     self.assert_result_file(expected_file, result_file)
     self.remove_file(result_file)
     table.close_live_table()