def test_can_win_on_non_empty_square_board_they_cannot_win(self):
   """Test whether _can_win function returns that a player can win on a non-empty square board they cannot win."""
   # Create non-empty tic-tac-toe game board that player 2 cannot win
   board = TicTacToeBoard()
   board.matrix[0] = [1, 2, 1]
   board.matrix[1] = [2, 1, 0]
   board.matrix[2] = [0, 0, 2]
   self.assertFalse(board._can_win(2))
   # Create non-empty tic-tac-toe game board that player 1 cannot win
   board = TicTacToeBoard()
   board.matrix[0] = [2, 1, 2]
   board.matrix[1] = [1, 2, 0]
   board.matrix[2] = [0, 0, 1]
   self.assertFalse(board._can_win(1))
 def test_can_win_on_empty_square_board(self):
   """Test whether _can_win function returns that a player can always win on an empty square board."""
   # Create empty tic-tac-toe game board
   board = TicTacToeBoard()
   # A perfect player is not guaranteed to win on an empty board
   self.assertFalse(board._can_win(1))
   self.assertFalse(board._can_win(2))
 def test_can_win_on_non_empty_square_board_you_lost(self):
   """Test whether _can_win function returns that a player cannot win a non-empty square board that they lost."""
   # Create non-empty tic-tac-toe game board that player 1 has won
   board = TicTacToeBoard()
   board.matrix[0] = [1, 0, 0]
   board.matrix[1] = [2, 1, 0]
   board.matrix[2] = [0, 2, 1]
   self.assertFalse(board._can_win(2))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [1, 0, 0]
   board.matrix[1] = [1, 2, 0]
   board.matrix[2] = [1, 2, 0]
   self.assertFalse(board._can_win(2))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [1, 1, 1]
   board.matrix[1] = [0, 2, 0]
   board.matrix[2] = [0, 2, 0]
   self.assertFalse(board._can_win(2))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [0, 2, 1]
   board.matrix[1] = [0, 1, 0]
   board.matrix[2] = [1, 2, 0]
   self.assertFalse(board._can_win(2))
   # Create non-empty tic-tac-toe game board that player 2 has won
   board = TicTacToeBoard()
   board.matrix[0] = [2, 0, 0]
   board.matrix[1] = [1, 2, 0]
   board.matrix[2] = [0, 1, 2]
   self.assertFalse(board._can_win(1))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [2, 0, 0]
   board.matrix[1] = [2, 1, 0]
   board.matrix[2] = [2, 1, 0]
   self.assertFalse(board._can_win(1))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [2, 2, 2]
   board.matrix[1] = [0, 1, 0]
   board.matrix[2] = [0, 1, 0]
   self.assertFalse(board._can_win(1))
   # Test another similar board
   board = TicTacToeBoard()
   board.matrix[0] = [0, 1, 2]
   board.matrix[1] = [0, 2, 0]
   board.matrix[2] = [2, 1, 0]
   self.assertFalse(board._can_win(1))