'Test setting the contents of a sub element.'

def testSubElement(self):

    class TestStanza(ElementBase, ):
        name = 'foo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz'))
        def setBaz(self, value):
            self._set_sub_text('wrapper/baz', text=value)
        def getBaz(self):
            return self._get_sub_text('wrapper/baz')
        def setBar(self, value):
            self._set_sub_text('wrapper/bar', text=value)
        def getBar(self):
            return self._get_sub_text('wrapper/bar')
    stanza = TestStanza()
    stanza['bar'] = 'a'
    stanza['baz'] = 'b'
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <wrapper>\n                                                        <bar>a</bar>\n                                                        <baz>b</baz>\n                                                </wrapper>\n                                        </foo>\n                                ')
    stanza._set_sub_text('wrapper/bar', text='', keep=True)
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <wrapper>\n                                                        <bar    />\n                                                        <baz>b</baz>\n                                                </wrapper>\n                                        </foo>\n                                ', use_values=False)
    stanza['bar'] = 'a'
    stanza._set_sub_text('wrapper/bar', text='')
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <wrapper>\n                                                        <baz>b</baz>\n                                                </wrapper>\n                                        </foo>\n                                ')
