'Test that plugin callbacks that return a value exit the loop.'

def test_plugin_callback_return(self):

    class DummyPlugin(plugins.BeetsPlugin, ):
        def __init__(self):
            super(DummyPlugin, self).__init__()
            self.register_listener('before_choose_candidate', self.return_choices)
        def return_choices(self, session, task):
            return [ui.commands.PromptChoice('f', u'Foo', self.foo)]
        def foo(self, session, task):
            return action.SKIP
    self.register_plugin(DummyPlugin)
    opts = ((u'Apply', u'More    candidates', u'Skip', u'Use    as-is', u'as    Tracks', u'Group    albums', u'Enter    search', u'enter    Id', u'aBort') + (u'Foo',))
    with helper.control_stdin('f\n'):
        self.importer.run()
    self.mock_input_options.assert_called_once_with(opts, default='a', require=ANY)
