Home | Trees | Indices | Help |
|
---|
|
1 # -*- coding: utf-8 -*- 2 import unittest, doctest 3 4 from common_imports import StringIO, etree, SillyFileLike, HelperTestCase 5 6 ascii_uni = u'a' 7 8 klingon = u"\uF8D2" # not valid for XML names 9 10 invalid_tag = "test" + klingon 11 12 uni = u'Ã\u0680\u3120' # some non-ASCII characters 13 14 uxml = u"<test><title>test á\u3120</title><h1>page á\u3120 title</h1></test>" 152064 65 ## def test_parse_fileobject_unicode(self): 66 ## # parse unicode from unamed file object (not support by ElementTree) 67 ## f = SillyFileLike(uxml) 68 ## root = etree.parse(f).getroot() 69 ## self.assertEquals(unicode(etree.tostring(root, 'UTF-8'), 'UTF-8'), 70 ## uxml) 7122 uxml = u'<?xml version="1.0" encoding="UTF-8"?>' + \ 23 u'<p>%s</p>' % uni 24 self.assertRaises(ValueError, etree.XML, uxml)25 29 33 3840 # sadly, Klingon is not well-formed 41 tag = u"{%s}%s" % (uni, invalid_tag) 42 self.assertRaises(ValueError, etree.Element, tag)4345 qname = etree.QName(uni, uni) 46 tag = u"{%s}%s" % (uni, uni) 47 self.assertEquals(qname.text, tag) 48 self.assertEquals(unicode(qname), tag)49 52 56 6073 suite = unittest.TestSuite() 74 suite.addTests([unittest.makeSuite(UnicodeTestCase)]) 75 return suite76
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0 on Fri Dec 12 22:47:09 2008 | http://epydoc.sourceforge.net |