'Directives in the document factory of an Element returned from a render
method of another Element are satisfied from the correct object: the
"inner" Element.'

def test_elementContainingDynamicElement(self):

    class OuterElement(Element, ):
        @renderer
        def outerMethod(self, request, tag):
            return tag(InnerElement(loader=XMLString('\n                                                                <t:ignored\n                                                                        xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"\n                                                                        t:render="innerMethod"    />\n                                                                ')))
    class InnerElement(Element, ):
        @renderer
        def innerMethod(self, request, tag):
            return 'Hello,    world.'
    element = OuterElement(loader=XMLString('\n                                <p    xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"\n                                        t:render="outerMethod"    />\n                                '))
    return self.assertFlattensTo(element, '<p>Hello,    world.</p>')
