Пример #1
0
    def test_add_get_methods(self):
        table = ResultTable(headers=["Column 0", "Column 1"])

        # add/get single result
        table.insert_row_by_index(["value 0,0", "value 0,1"])
        self.assertEqual(table.get_row_by_index(index=0),
                         ["value 0,0", "value 0,1"])
        table.insert_row_by_index(["value -1,0", "value -1,1"], index=0)
        self.assertEqual(table.get_row_by_index(index=0),
                         ["value -1,0", "value -1,1"])
        table.insert_row_by_index(["value 1,0", "value 1,1"], index=2)
        self.assertEqual(table.get_row_by_index(index=2),
                         ["value 1,0", "value 1,1"])
Пример #2
0
    def test_remove_methods(self):
        table = ResultTable(headers=TEST_HEADERS)
        # Pick a row
        row_idx = 4

        with self.assertRaises(TritonModelAnalyzerException):
            table.remove_row_by_index(index=row_idx)

        # Fill table
        for row in TEST_ROWS:
            table.insert_row_by_index(row)

        self.assertEqual(table.get_row_by_index(index=row_idx),
                         [f"value 4{j}" for j in range(10)])

        # remove rows and check that the next one is in its place
        table.remove_row_by_index(index=row_idx)
        self.assertEqual(table.get_row_by_index(index=row_idx),
                         [f"value 5{j}" for j in range(10)])

        # Remove all rows and then one
        with self.assertRaises(TritonModelAnalyzerException):
            for i in range(10):
                table.remove_row_by_index(index=0)