def test_tic_tac_toe_check_doesnt_accept_non_string_boards(self, board): with pytest.raises( TypeError, message= "Method is supposed to raise TypeError on lists not containing all strings" ): tic_tac_toe_check(board)
def test_horizontal_row_two_winner(self): """ Asserts that the winning character is returned if a winner in the second row is found """ try: impl.tic_tac_toe_check(["o", "o", "", "x", "x", "x", "", "", "o"]) assert True except: assert False
def test_tic_tac_toe_check_not_empty_string(self): tmp1 = list(FULL_BOARD_CONFIG) tmp1[0] = ' ' with self.assertRaises( ValueError, message="does not flag invalid empty position string"): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_multiple_winning_patterns(): tmp1 = list(FULL_BOARD_CONFIG) tmp1[8] = 'x' tmp1[0] = 'o' with pytest.raises(ValueError, message="does not flag multiple winning patterns"): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_only_accepts_lists_with_lowercase_x_or_o_or_empty( self): with pytest.raises( ValueError, message="Method is supposed to raise ValueError on lists not" " containing all 'x's, 'o's, and/or ''."): tic_tac_toe_check(["x", "o", "o", "x", "o", "x", "1", "z", "y"])
def test_bottom_left_to_top_right_diagonal_winner(self): """ Asserts that the winning character is returned if a winner in the bottom to top diagonal """ try: impl.tic_tac_toe_check(["o", "o", "x", "o", "x", "", "x", "", ""]) assert True except: assert False
def test_passes_if_board_is_legal(self): """ Asserts that no error is raised if the given board is a legal board """ try: impl.tic_tac_toe_check(["", "", "", "", "", "", "", "", ""]) assert True except: assert False
def test_tic_tac_toe_check_raises_value_error_on_multiple_winning_patterns( self, board): with pytest.raises( ValueError, message= "Method is supposed to raise ValueError on multiple winners."): tic_tac_toe_check(board)
def test_vertical_column_three_winner(self): """ Asserts that the winning character is returned if a winner in the third vertical column is found """ try: impl.tic_tac_toe_check(["o", "", "x", "o", "", "x", "", "o", "x"]) assert True except: assert False
def test_tic_tac_toe_check_only_accepts_correct_board_size_lists( self, board): with pytest.raises( ValueError, message= "Method is supposed to raise ValueError on incorrectly sized lists." ): tic_tac_toe_check(board)
def test_raises_if_board_contains_more_than_one_winner(self): """ Asserts that ValueError is raised if the board contains more than one winner """ try: impl.tic_tac_toe_check(["x", "x", "x", "o", "o", "o", "", "", ""]) assert False except ValueError: assert True except: assert False
def test_raises_if_board_is_not_length_nine(self): """ Asserts that ValueError is raised if the board is not exactly nine strings """ try: impl.tic_tac_toe_check([""]) assert False except ValueError: assert True except: assert False
def test_raises_if_board_contains_invalid_characters(self): """ Asserts that ValueError is raised if the board contains invalid characters """ try: impl.tic_tac_toe_check(["", "", "", "", "", "", "", "", "z"]) assert False except ValueError: assert True except: assert False
def test_raises_if_board_is_none(self): """ Asserts that TypeError is raised if the given board is None """ try: impl.tic_tac_toe_check(None) assert False except TypeError: assert True except: assert False
def test_raises_if_board_is_non_list(self): """ Asserts that TypeError is raised if the given board is not a list """ try: impl.tic_tac_toe_check("board") assert False except TypeError: assert True except: assert False
def test_tic_tac_toe_check_invalid_symbol_type1(): with pytest.raises(TypeError, message="does not flag invalid arg type"): impl.tic_tac_toe_check([1] * 9) with pytest.raises(TypeError, message="does not flag invalid arg type"): impl.tic_tac_toe_check([None] * 9) tmp1 = list(FULL_BOARD_CONFIG) tmp1[0] = 1 with pytest.raises(TypeError, message="does not flag invalid arg type"): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_invalid_symbol_type1(): with pytest.raises(TypeError): impl.tic_tac_toe_check([1] * 9) with pytest.raises(TypeError): impl.tic_tac_toe_check([None] * 9) tmp1 = list(FULL_BOARD_CONFIG) tmp1[0] = 1 with pytest.raises(TypeError): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_returns_o_as_winner(self, board): winner = tic_tac_toe_check(board) assert winner == 'o'
def test_tic_tac_toe_check_incorrect_board_type1(): with pytest.raises(TypeError, message="does not flag invalid arg type"): impl.tic_tac_toe_check(None) with pytest.raises(TypeError): impl.tic_tac_toe_check(3)
def test_tic_tac_toe_check_accepts_all_winning_pattern_types(self, board): winner = tic_tac_toe_check(board) assert winner == 'x'
def test_tic_tac_toe_check_multiple_symbols(): tmp1 = list(FULL_BOARD_CONFIG) tmp1[0] = 'y' with pytest.raises(ValueError, message="does not flag invalid symbols"): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_doesnt_return_empty_string_as_winner(self): winner = tic_tac_toe_check(["x", "o", "x", "", "", "", "x", "o", "x"]) assert winner != ""
def test_tic_tac_toe_check_only_accepts_lists(self, board): with pytest.raises( TypeError, message= "Method is supposed to raise TypeError on non-list inputs"): tic_tac_toe_check(board)
def test_tic_tac_toe_check_partial_board(): tmp1 = list(FULL_BOARD_CONFIG) tmp1[0] = '' assert impl.tic_tac_toe_check( tmp1) == None, "fails to return None when there is no winner"
def test_tic_tac_toe_check_no_winning_pattern(): tmp1 = list(FULL_BOARD_CONFIG) assert impl.tic_tac_toe_check( tmp1) == None, "fails to return None when there is no winner"
def test_tic_tac_toe_check_returns_none_on_list_of_empties(self): value = tic_tac_toe_check(["", "", "", "", "", "", "", "", ""]) assert value is None
def test_tic_tac_toe_check_incorrect_board_size(): with pytest.raises(ValueError, message="does not flag invalid board size"): impl.tic_tac_toe_check(['x'] * 3)
def test_tic_tac_toe_check_returns_none_on_no_winners(self): winner = tic_tac_toe_check( ["x", "o", "x", "x", "x", "o", "o", "x", "o"]) assert winner is None
def test_tic_tac_toe_check_not_o(): tmp1 = list(FULL_BOARD_CONFIG.replace('o', 'd')) with pytest.raises(ValueError, message="does not flag invalid symbols"): impl.tic_tac_toe_check(tmp1)
def test_tic_tac_toe_check_x_based_winning_pattern(): tmp1 = list(FULL_BOARD_CONFIG) tmp1[6] = 'x' assert impl.tic_tac_toe_check( tmp1) == 'x', "fails to recognize x based winning pattern"