def test_3x_in_a_row(self): for i, board in enumerate(("XXXO O O", "O XXXO O", "O OO XXX")): with self.subTest(row=i + 1): self.assertEqual(tic_tac_toe_winner(board), "X")
def test_illegal_symbols(self): with self.assertRaises(ValueError): tic_tac_toe_winner(" E ")
def test_too_large_board(): with pytest.raises(ValueError): tic_tac_toe_winner("XOOOXXXXOX")
def test_3x_diagonally(): # pytest keep it out of class assert tic_tac_toe_winner("XO OX X") == "X"
def test_empty_board(self): self.assertIsNone(tic_tac_toe_winner(" " * 9))
def test_3x_in_a_column(self): self.assertEqual(tic_tac_toe_winner("X XO XOO"), "X")
def test_3x_in_a_row(): winner = tic_tac_toe_winner("XXX O O ") assert winner == "X", f"expected X, got {winner}"
def test_empty_board(): assert tic_tac_toe_winner(" " * 9) is None
def test_illegal_board_size(): try: tic_tac_toe_winner("XXX") assert False, "ValueError expected" except ValueError: pass
def test_illegal_board_symbols(): try: tic_tac_toe_winner("Ala ma kota") assert False, "ValueError expected" except ValueError: pass