Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
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)
Ejemplo n.º 5
0
 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"])
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
 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
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 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
Ejemplo n.º 12
0
 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
Ejemplo n.º 13
0
 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
Ejemplo n.º 14
0
 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
Ejemplo n.º 15
0
 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
Ejemplo n.º 16
0
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)
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
 def test_tic_tac_toe_check_returns_o_as_winner(self, board):
     winner = tic_tac_toe_check(board)
     assert winner == 'o'
Ejemplo n.º 19
0
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)
Ejemplo n.º 20
0
 def test_tic_tac_toe_check_accepts_all_winning_pattern_types(self, board):
     winner = tic_tac_toe_check(board)
     assert winner == 'x'
Ejemplo n.º 21
0
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)
Ejemplo n.º 22
0
 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 != ""
Ejemplo n.º 23
0
 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)
Ejemplo n.º 24
0
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"
Ejemplo n.º 25
0
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"
Ejemplo n.º 26
0
 def test_tic_tac_toe_check_returns_none_on_list_of_empties(self):
     value = tic_tac_toe_check(["", "", "", "", "", "", "", "", ""])
     assert value is None
Ejemplo n.º 27
0
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)
Ejemplo n.º 28
0
 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
Ejemplo n.º 29
0
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)
Ejemplo n.º 30
0
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"