Пример #1
0
def test_row():
    """Test basic properties of the row() function."""
    board = Board()
    assert len(board.row(0)) == board.size
    board.make_move((0, 1), 1)
    board.integrity_check()
    board.make_move((0, 2), 3)
    board.integrity_check()
    board.make_move((0, 4), 13)
    board.integrity_check()
    expected_row = np.asarray([EMPTY_CELL, 1, 3, EMPTY_CELL, 13])
    assert all(board.row(0) == expected_row)
Пример #2
0
def test_make_move():
    """Test making move and updating member variables."""
    board = Board()
    board.make_move((0, 0), 13)
    assert len(list(board.possible_moves())) == 5 * 5 - 1
    assert all(board.row(0) == board.col(0))
    assert (0, 0) not in board.possible_moves()
    assert board.occupied_cells == 1

    board.make_move((4, 4), 1)
    assert (4, 4) not in board.possible_moves()
    assert (4, 3) in board.possible_moves()

    with pytest.raises(ValueError):
        board.make_move((4, 4), 5)