def test_generate_full_sudoku(self): s_gen_1 = Sudoku() s_gen_1.generate_full_sudoku() assert s_gen_1.validate() is True s_gen_2 = Sudoku() s_gen_2.generate_full_sudoku() assert s_gen_2.validate() is True s_gen_3 = Sudoku() s_gen_3.generate_full_sudoku() assert s_gen_3.validate() is True
def test_generate_sudoku(self): # Check whether the correct amount of empty cells was removed # / generated. s_gen_1 = Sudoku() s_gen_1.generate_full_sudoku() empty_cells = 48 s_gen_1.generate_sudoku(empty_cells) counter = 0 for y in range(0, 9): for x in range(0, 9): if s_gen_1.grid[y][x] == 0: counter += 1 if s_gen_1.solved_grid[y][x] == 0: counter += 1 assert counter == empty_cells # Test for valid solution. generated_solution = s_gen_1.solved_grid s_gen_1.solved_grid = s_gen_1.empty_grid s_gen_1.quick_solve(False) assert generated_solution == s_gen_1.solved_grid # Test whether the generated Sudoku is valid assert s_gen_1.validate() is True