示例#1
0
def test_empty_board():
    assert tic_tac_toe_winner(" " * 9) is None
示例#2
0
def test_3x_in_a_row():
    winner = tic_tac_toe_winner("XXX O O  ")
    assert winner == "X", f"expected X, got {winner}"
示例#3
0
def test_illegal_board_symbols():
    try:
        tic_tac_toe_winner("Ala ma kota")
        assert False, "ValueError expected"
    except ValueError:
        pass
示例#4
0
def test_illegal_board_size():
    try:
        tic_tac_toe_winner("XXX")
        assert False, "ValueError expected"
    except ValueError:
        pass
示例#5
0
def test_no_winner():
    winner = tic_tac_toe_winner('XOXOXOOXO')
    assert winner == None, f"expected None, got {winner}"
示例#6
0
def test_3x_in_diagonal_2():
    winner = tic_tac_toe_winner(' OXOX X O')
    assert winner == 'X', f"expected X, got {winner}"
示例#7
0
def test_3x_in_a_col():
    winner = tic_tac_toe_winner('XOXXO X O')
    assert winner == 'X', f"expected X, got {winner}"
示例#8
0
def test_illegal_board_game():
    try:
        tic_tac_toe_winner('XXX O    ')
        assert False, "ValueError expected"
    except ValueError:
        pass
示例#9
0
 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")
示例#10
0
def test_3x_in_a_row():
    winner = tic_tac_toe_winner('XXX O O  ')
    assert winner == 'X', f"expected X, got {winner}"
示例#11
0
def test_too_large_board():
    with pytest.raises(ValueError):
        tic_tac_toe_winner("XOOOXXXXOX")
示例#12
0
 def test_illegal_symbols(self):
     with self.assertRaises(ValueError):
         tic_tac_toe_winner("    E    ")
示例#13
0
 def test_empty_board(self):
     self.assertIsNone(tic_tac_toe_winner(" " * 9))
示例#14
0
def test_3x_diagonally():  # pytest keep it out of class
    assert tic_tac_toe_winner("XO OX   X") == "X"
示例#15
0
 def test_3x_in_a_column(self):
     self.assertEqual(tic_tac_toe_winner("X  XO XOO"), "X")