sudoku-solver/tests.py

41 lines
916 B
Python
Raw Normal View History

2019-11-30 15:21:33 +01:00
"""All tests for the Sudoku Solver."""
import unittest
from square import Square
class TestSquare(unittest.TestCase):
"""TestCase for Square"""
def setUp(self):
content = '.'
self.board = [
Square(line, column, content)
for line in range(9)
for column in range(9)
]
self.assertEqual(len(self.board), 81)
def test_grid_is_correctly_computed(self):
"""Square.grid is correctly computed for all values."""
correct_grids = (
"000111222"
"000111222"
"000111222"
"333444555"
"333444555"
"333444555"
"666777888"
"666777888"
"666777888"
)
for i, square in enumerate(self.board):
self.assertEqual(square.grid_id, int(correct_grids[i]))
2019-11-30 15:21:33 +01:00
if __name__ == '__main__':
unittest.main()