def METHOD_NAME(self):
    with TestContext.create_memory_context() as test_context:
        document_controller = test_context.create_document_controller()
        document_model = document_controller.document_model
        data_item = DataItem.DataItem(numpy.ones((8, 8)))
        document_model.append_data_item(data_item)
        recorder_state_ref = ["unknown"]
        def recorder_state_changed(recorder_state): recorder_state_ref[0] = recorder_state
        recorder = RecorderPanel.Recorder(document_controller, data_item)
        recorder.on_recording_state_changed = recorder_state_changed
        with contextlib.closing(recorder):
            with document_model.data_item_live(data_item):
                count = 4
                recorder.start_recording(10, 1, count)
                for i in range(count):
                    recorder.continue_recording(10 + i + 0.25)
                    data_item.set_data(data_item.data + 1)
                    if i != count - 1:  # last iteration it should fall out of transaction state since it is finished
                        self.assertEqual(recorder_state_ref[0], "recording")
                    else:
                        self.assertEqual(recorder_state_ref[0], "stopped")
            self.assertEqual(recorder_state_ref[0], "stopped")