Beispiel #1
0
    def test_color_line(self):

        should_be = [
            ['0', '0', '0', '0', '0'],
            ['0', 'A', 'A', 'A', 'A'],
            ['0', '0', '0', '0', '0'],
        ]
        matrix = main.create_matrix(5, 3)
        main.color_line(matrix, 2, 5, 2, 'A')
        self.assertEqual(matrix, should_be)
Beispiel #2
0
 def test_color_region_2(self):
     should_be = [
         ['0', '0', '0', '0', '0'],
         ['A', 'A', 'A', 'A', 'A'],
         ['B', 'B', 'B', 'B', 'B'],
     ]
     matrix = main.create_matrix(5, 3)
     main.color_line(matrix, 1, 5, 2, 'A')
     original_color = '0'
     main.color_region(matrix, 4, 3, 'B', original_color)
     self.assertEqual(matrix, should_be)
Beispiel #3
0
    def test_write_file(self):
        # Removing previous file
        if os.path.isfile('teste.txt'):
            os.unlink('teste.txt')

        should_be = '0000\n0000\nBBBB\n'
        matrix = main.create_matrix(4, 3)
        main.color_line(matrix, 1, 4, 3, 'B')
        main.write_file(matrix, 'teste.txt')
        self.assertTrue(os.path.isfile('teste.txt'))
        self.assertEqual(open('teste.txt', 'r').read(), should_be)