Example #1
0
 def test_unicode_to_xml(self):
     tools.ok_(converters.unicode_to_xml(None) == '')
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml, *['byte string'])
     tools.assert_raises(ValueError, converters.unicode_to_xml, *[u'string'], **{'control_chars': 'foo'})
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml,
             *[u'string\u0002'], **{'control_chars': 'strict'})
     tools.ok_(converters.unicode_to_xml(self.u_entity) == self.utf8_entity_escape)
     tools.ok_(converters.unicode_to_xml(self.u_entity, attrib=True) == self.utf8_attrib_escape)
Example #2
0
 def test_unicode_to_xml(self):
     tools.eq_(converters.unicode_to_xml(None), b'')
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml, *[b'byte string'])
     tools.assert_raises(ValueError, converters.unicode_to_xml, *['string'], **{'control_chars': 'foo'})
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml,
             *['string\u0002'], **{'control_chars': 'strict'})
     tools.eq_(converters.unicode_to_xml(self.u_entity), self.utf8_entity_escape)
     tools.eq_(converters.unicode_to_xml(self.u_entity, attrib=True), self.utf8_attrib_escape)
     tools.eq_(converters.unicode_to_xml(self.u_entity, encoding='ascii'), self.ascii_entity_escape)
     tools.eq_(converters.unicode_to_xml(self.u_entity, encoding='ascii', attrib=True), self.ascii_attrib_escape)
 def test_unicode_to_xml(self):
     tools.eq_(converters.unicode_to_xml(None), b'')
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml,
                         *[b'byte string'])
     tools.assert_raises(ValueError, converters.unicode_to_xml, *['string'],
                         **{'control_chars': 'foo'})
     tools.assert_raises(XmlEncodeError, converters.unicode_to_xml,
                         *['string\u0002'], **{'control_chars': 'strict'})
     tools.eq_(converters.unicode_to_xml(self.u_entity),
               self.utf8_entity_escape)
     tools.eq_(converters.unicode_to_xml(self.u_entity, attrib=True),
               self.utf8_attrib_escape)
     tools.eq_(converters.unicode_to_xml(self.u_entity, encoding='ascii'),
               self.ascii_entity_escape)
     tools.eq_(
         converters.unicode_to_xml(self.u_entity,
                                   encoding='ascii',
                                   attrib=True), self.ascii_attrib_escape)