'Test removing sub elements.'

def testDelSub(self):

    class TestStanza(ElementBase, ):
        name = 'foo'
        namespace = 'foo'
        interfaces = set(('bar', 'baz'))
        def setBar(self, value):
            self._set_sub_text('path/to/only/bar', value)
        def getBar(self):
            return self._get_sub_text('path/to/only/bar')
        def delBar(self):
            self._del_sub('path/to/only/bar')
        def setBaz(self, value):
            self._set_sub_text('path/to/just/baz', value)
        def getBaz(self):
            return self._get_sub_text('path/to/just/baz')
        def delBaz(self):
            self._del_sub('path/to/just/baz')
    stanza = TestStanza()
    stanza['bar'] = 'a'
    stanza['baz'] = 'b'
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <path>\n                                                        <to>\n                                                                <only>\n                                                                        <bar>a</bar>\n                                                                </only>\n                                                                <just>\n                                                                        <baz>b</baz>\n                                                                </just>\n                                                        </to>\n                                                </path>\n                                        </foo>\n                                ')
    del stanza['bar']
    del stanza['baz']
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <path>\n                                                        <to>\n                                                                <only    />\n                                                                <just    />\n                                                        </to>\n                                                </path>\n                                        </foo>\n                                ', use_values=False)
    stanza['bar'] = 'a'
    stanza['baz'] = 'b'
    stanza._del_sub('path/to/only/bar', all=True)
    self.check(stanza, '\n                                        <foo    xmlns="foo">\n                                                <path>\n                                                        <to>\n                                                                <just>\n                                                                        <baz>b</baz>\n                                                                </just>\n                                                        </to>\n                                                </path>\n                                        </foo>\n                                ')
