def test_attributes_without_text(self): attrs = Attributes(None, {"one": "two"}) p2x = PyToXml("a", {"b": attrs}) p2x.add_type_handler(Attributes) self.assertEqual(str(p2x.encode()), "<a><b one=\"two\"/></a>")
def test_attributes_without_text(self): attrs = Attributes(None, { "one": "two" }) p2x = PyToXml("a", { "b": attrs } ) p2x.add_type_handler(Attributes) self.assertEqual(str(p2x.encode()), "<a><b one=\"two\"/></a>")
def test_add_type_handler(self): def temp_convertor(structure, element, name, pytoxml): element.text = str(structure) p2x = PyToXml("a", { "b": Exception("Should now serialise") }) p2x.add_type_handler(Exception, temp_convertor) self.assertEqual(str(p2x.encode()), "<a><b>Should now serialise</b></a>")
def test_add_type_handler(self): def temp_convertor(structure, element, name, pytoxml): element.text = str(structure) p2x = PyToXml("a", {"b": Exception("Should now serialise")}) p2x.add_type_handler(Exception, temp_convertor) self.assertEqual(str(p2x.encode()), "<a><b>Should now serialise</b></a>")