<commit_before>
import unittest
from eatable import Table, Row

class TableTestCase(unittest.TestCase):
    """Test the methods of Table"""

    def setUp(self):
        self.header = ['A', 'B', 'C']

    def test_from_csv_file(self):
        table = Table.from_csv_file("tests/simple.csv")
        self.assertEqual(len(table), 3)

    def test_init(self):
        table = Table(self.header)
        self.assertEqual(table.width, len(self.header))

    def test_getitem(self):
        table = Table(self.header)
        table.append(('a', 'b', 'c'))
        row = table[0]
        self.assertIsInstance(row, Row)

    def test_setitem(self):
        new_data = ('a2', 'b2', 'c2')
        table = Table(self.header)
        table.append(('a1', 'b1', 'c1'))
        table[0] = new_data
        self.assertEqual(table.data[0], new_data)

    def test_get_column_index(self):
        table = Table(self.header)
        self.assertEqual(table.get_column_index('A'), 0)
        self.assertEqual(table.get_column_index('B'), 1)
        self.assertEqual(table.get_column_index('C'), 2)
        self.assertEqual(table.get_column_index(0), 0)
        self.assertEqual(table.get_column_index(1), 1)
        self.assertEqual(table.get_column_index(2), 2)

        with self.assertRaises(IndexError):
            table.get_column_index(10)
        with self.assertRaises(KeyError):
            table.get_column_index('D')
        with self.assertRaises(TypeError):
            table.get_column_index(['E'])

    def test_append(self):
        table = Table(self.header)
        for i in range(5):
            table.append(('a' + str(i), 'b' + str(i), 'c' + str(i)))

        self.assertEqual(len(table), 5)
        for i in range(5):
            self.assertIsInstance(table.data[i], tuple)

if __name__ == '__main__':
    unittest.main()
<commit_msg>cleanup TableTestCase and add more cases<commit_after>
import unittest
from eatable import Table, Row

class TableTestCase(unittest.TestCase):
    """Test the methods of Table"""

    def setUp(self):
        self.header = ['A', 'B', 'C']
        self.length = 3
        self.table = Table(self.header)
        for i in range(self.length):
            self.table.append(('a' + str(i), 'b' + str(i), 'c' + str(i)))

    def test_from_csv_file(self):
        table = Table.from_csv_file("tests/simple.csv")
        self.assertEqual(len(table), 3)

    def test_init_append(self):
        self.assertEqual(self.table.width, len(self.header))
        self.assertEqual(self.table.data[0], ('a0', 'b0', 'c0'))
        self.assertEqual(self.table.data[1], ('a1', 'b1', 'c1'))
        self.assertEqual(self.table.data[2], ('a2', 'b2', 'c2'))

    def test_getitem(self):
        row = self.table[0]
        self.assertIsInstance(row, Row)

    def test_setitem(self):
        self.table[0] = ('x1', 'y1', 'z1')
        self.assertEqual(self.table.data[0], ('x1', 'y1', 'z1'))

    def test_append(self):
        # normal case is already tested
        with self.assertRaises(AssertionError):
            self.table.append((1, 2, 3, 4))

    def test_get_row(self):
        row = self.table.get_row(0)
        self.assertIsInstance(row, Row)
        self.assertEqual(row.table, self.table)
        self.assertEqual(row.index, 0)

        with self.assertRaises(IndexError):
            self.table.get_row(30)

    def test_set_row(self):
        self.table.set_row(0, range(3))
        self.assertEqual(self.table.data[0], tuple(range(3)))

        with self.assertRaises(IndexError):
            self.table.set_row(30, range(3))


    def test_get_column_index(self):
        self.assertEqual(self.table.get_column_index('A'), 0)
        self.assertEqual(self.table.get_column_index('B'), 1)
        self.assertEqual(self.table.get_column_index('C'), 2)
        self.assertEqual(self.table.get_column_index(0), 0)
        self.assertEqual(self.table.get_column_index(1), 1)
        self.assertEqual(self.table.get_column_index(2), 2)

        with self.assertRaises(IndexError):
            self.table.get_column_index(10)
        with self.assertRaises(KeyError):
            self.table.get_column_index('D')
        with self.assertRaises(TypeError):
            self.table.get_column_index(['E'])

if __name__ == '__main__':
    unittest.main()

{'fraction_non_alphanumeric': 0.14846855272387188, 'fraction_numerical': 0.01706803834463409, 'mean_word_length': 2.755926251097454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1262711', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1405, 'n_words': 251}