def test_empty_undo():
    '''
    Check that undoing an empty board doesn't break.
    '''
    patient = GameState(3)
    patient.undo()
    assert(patient.player_to_act() == BoardValues.X)
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)