def test_to_string(self): data = { 'test': { 'nodes': { 'node': ['Testing', 'Another node'] }, } } x = xml.from_dict(data) s = xml.to_string(x) expected_output = '<test><nodes><node>Testing</node><node>Another node</node></nodes></test>' declaration = '<?xml version="1.0" encoding="utf-8" ?>' assert s == expected_output assert xml.to_string( x, xml_declaration=True) == declaration + expected_output
def test_to_string(self): data = { 'test': { 'nodes': { 'node': [ 'Testing', 'Another node' ] }, } } x = xml.from_dict(data) s = xml.to_string(x) expected_output = '<test><nodes><node>Testing</node><node>Another node</node></nodes></test>' declaration = '<?xml version="1.0" encoding="utf-8" ?>' assert s == expected_output assert xml.to_string(x, xml_declaration=True) == declaration + expected_output
def __call__(self, view_model, context=None): _xml = xml.from_dict(view_model.data) return xml.to_string(_xml, xml_declaration=True)
def __call__(self, view_model, context=None): data = view_model.data if view_model.template in shared.TEMPLATES.keys(): data = self._formatted_error(view_model, context) _xml = xml.from_dict(data) return xml.to_string(_xml, xml_declaration=True)