def METHOD_NAME(
    qtbot, nframes=8, fps=20, frame_range=None, loop_mode=LoopMode.LOOP
):
    # sets up an AnimationWorker ready for testing, and breaks down when done
    dims = Dims(ndim=4)
    qtdims = QtDims(dims)
    qtbot.addWidget(qtdims)
    nz = 8
    step = 1
    dims.set_range(0, (0, nz - 1, step))
    slider_widget = qtdims.slider_widgets[0]
    slider_widget.loop_mode = loop_mode
    slider_widget.fps = fps
    slider_widget.frame_range = frame_range
    worker = AnimationWorker(slider_widget)
    worker._count = 0
    worker.nz = nz
    def bump(*args):
        if worker._count < nframes:
            worker._count += 1
        else:
            worker._stop()
    def count_reached():
        assert worker._count >= nframes
    def go():
        worker.work()
        qtbot.waitUntil(count_reached, timeout=6000)
        worker._stop()
        return worker.current
    worker.frame_requested.connect(bump)
    worker.go = go
    yield worker