def test_winner_after_undo():
    '''
    Check that undoing a move after a win no longer results in a win.
    '''
    patient = GameState(3)
    assert_no_winner(patient)
    patient.play(patient._spaces.index(0, 0)) \
        .play(patient._spaces.index(1, 0)) \
        .play(patient._spaces.index(1, 1)) \
        .play(patient._spaces.index(1, 2)) \
        .play(patient._spaces.index(2, 2))
    assert_X_wins(patient)
    patient.undo()
    assert_no_winner(patient)
    assert(not patient.is_terminal())
    assert(patient.num_legal_actions() == 5)
def test_draw():
    '''
    Check that the match is drawn
    '''
    patient = GameState(3)
    assert_no_winner(patient)
    patient.play(patient._spaces.index(0, 0)) \
        .play(patient._spaces.index(1, 0)) \
        .play(patient._spaces.index(0, 1)) \
        .play(patient._spaces.index(1, 1)) \
        .play(patient._spaces.index(1, 2)) \
        .play(patient._spaces.index(0, 2)) \
        .play(patient._spaces.index(2, 0)) \
        .play(patient._spaces.index(2, 1)) \
        .play(patient._spaces.index(2, 2))
    assert(patient.is_terminal())
    assert(patient.score(BoardValues.X) == 0)
    assert(patient.is_terminal())
    assert(patient.num_legal_actions() == 0)