'test that templates used via <%namespace> have access to an inheriting \'self\', and that
the full \'self\' is also exported.'

def test_namespaces(self):

    collection = lookup.TemplateLookup()
    collection.put_string('base', '\n                                <%def    name="a()">base_a</%def>\n                                <%def    name="b()">base_b</%def>\n                                This    is    the    base.\n                                ${next.body()}\n')
    collection.put_string('layout', '\n                                <%inherit    file="base"/>\n                                <%def    name="a()">layout_a</%def>\n                                This    is    the    layout..\n                                ${next.body()}\n')
    collection.put_string('index', '\n                                <%inherit    file="base"/>\n                                <%namespace    name="sc"    file="secondary"/>\n                                this    is    index.\n                                a    is:    ${self.a()}\n                                sc.a    is:    ${sc.a()}\n                                sc.b    is:    ${sc.b()}\n                                sc.c    is:    ${sc.c()}\n                                sc.body    is:    ${sc.body()}\n')
    collection.put_string('secondary', '\n                                <%inherit    file="layout"/>\n                                <%def    name="c()">secondary_c.        a    is    ${self.a()}    b    is    ${self.b()}    d    is    ${self.d()}</%def>\n                                <%def    name="d()">secondary_d.</%def>\n                                this    is    secondary.\n                                a    is:    ${self.a()}\n                                c    is:    ${self.c()}\n')
    assert (result_lines(collection.get_template('index').render()) == ['This    is    the    base.', 'this    is    index.', 'a    is:    base_a', 'sc.a    is:    layout_a', 'sc.b    is:    base_b', 'sc.c    is:    secondary_c.    a    is    layout_a    b    is    base_b    d    is    secondary_d.', 'sc.body    is:', 'this    is    secondary.', 'a    is:    layout_a', 'c    is:    secondary_c.    a    is    layout_a    b    is    base_b    d    is    secondary_d.'])
