def METHOD_NAME():
    """Test that cancellation closes a generator with a finally clause."""
    closed = False
    def test_generator():
        try:
            i = 0
            while True:
                yield i
                i += 1
        finally:
            nonlocal closed
            closed = True
    pbr = cancelable_progress(test_generator())
    for i in pbr:
        if i == 5:
            pbr.cancel()
    assert pbr.is_canceled
    assert closed