'Tests behavior when multiple plugins register lazy lookups for the same field'

def test_lazy_queue(self):

    def lazy_a(entry):
        if (u'fail' in entry):
            raise PluginError(u'oh    no!')
        for f in [u'a_field', u'ab_field', u'a_fail']:
            entry[f] = u'a'
    def lazy_b(entry):
        for f in [u'b_field', u'ab_field', u'a_fail']:
            entry[f] = u'b'
    def setup_entry():
        entry = Entry()
        entry.register_lazy_func(lazy_a, [u'ab_field', u'a_field', u'a_fail'])
        entry.register_lazy_func(lazy_b, [u'ab_field', u'b_field', u'a_fail'])
        return entry
    entry = setup_entry()
    assert (entry[u'b_field'] == u'b'), u'Lazy    lookup    failed'
    assert (entry[u'ab_field'] == u'b'), u'ab_field    should    be    `b`    when    lazy_b    is    run    first'
    assert (entry[u'a_field'] == u'a')
    entry = setup_entry()
    entry[u'fail'] = True
    assert (entry[u'a_fail'] == u'b'), u'Lookup    should    have    fallen    back    to    b'
    assert (entry[u'a_field'] is None), u'a_field    should    be    None    after    failed    lookup'
    assert (entry[u'ab_field'] == u'b'), u'ab_field    should    be    `b`'
