def test_namespaced_attributes(self): """ XML attributes that are `QualifiedName` instances or use Clark notation produce namespaced XML element attributes. """ ns = Namespace('http://example.com', 'ex') attrib = {ns.key: 'value'} self.assertEqual( {'{http://example.com}tag': { '@{http://example.com}key': 'value' }}, element_to_dict(ns.tag(attrib))) attrib = {'{http://example.com}key': 'value'} self.assertEqual( {'{http://example.com}tag': { '@{http://example.com}key': 'value' }}, element_to_dict(ns.tag(attrib)))
def test_namespaced_attributes(self): """ XML attributes that are `QualifiedName` instances or use Clark notation produce namespaced XML element attributes. """ ns = Namespace('http://example.com', 'ex') attrib = {ns.key: 'value'} self.assertEqual( {'{http://example.com}tag': { '@{http://example.com}key': 'value'}}, element_to_dict(ns.tag(attrib))) attrib = {'{http://example.com}key': 'value'} self.assertEqual( {'{http://example.com}tag': { '@{http://example.com}key': 'value'}}, element_to_dict(ns.tag(attrib)))
def test_namespaced(self): """ Tags that are `QualifiedName` instances or use Clark notation produce namespaced XML elements. """ E = ElementMaker() self.assertEqual('<ns0:tag xmlns:ns0="http://example.com" />', tostring(E('{http://example.com}tag'))) self.assertEqual( '<ns0:tag xmlns:ns0="http://example.com" />', tostring(QualifiedName('http://example.com', 'tag')())) ns = Namespace('http://example.com', 'ex') self.assertEqual('<ex:tag xmlns:ex="http://example.com" />', tostring(ns.tag()))
def test_namespaced(self): """ Tags that are `QualifiedName` instances or use Clark notation produce namespaced XML elements. """ E = ElementMaker() self.assertEqual( '<ns0:tag xmlns:ns0="http://example.com" />', tostring(E('{http://example.com}tag'))) self.assertEqual( '<ns0:tag xmlns:ns0="http://example.com" />', tostring(QualifiedName('http://example.com', 'tag')())) ns = Namespace('http://example.com', 'ex') self.assertEqual( '<ex:tag xmlns:ex="http://example.com" />', tostring(ns.tag()))