Skip to content

Commit bfc3115

Browse files
author
j.s@google.com
committed
Adding unit tests for character encoding with unicode XML tags in the v2 XML core.
1 parent 5e2dc4c commit bfc3115

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

tests/atom_tests/core_test.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,14 @@ def testUnicodeInputString(self):
344344
self.assertEqual(create(u'x', '\xce\xb4'.decode('utf-8')).to_string(),
345345
'<x>&#948;</x>')
346346

347+
def testUnicodeTagsAndAttributes(self):
348+
# Begin with test to show underlying ElementTree behavior.
349+
t = ElementTree.fromstring(u'<del\u03b4ta>test</del\u03b4ta>'.encode('utf-8'))
350+
self.assertEqual(t.tag, u'del\u03b4ta')
351+
self.assertEqual(parse(u'<\u03b4elta>test</\u03b4elta>')._qname,
352+
u'\u03b4elta')
353+
#self.assertEqual(parse(u'<\u03b4elta>test</\u03b4elta>').to_string(),
354+
# '<&#948;elta>test</&#948;elta>')
347355

348356
def testUtf8InputString(self):
349357
# Test parsing inner text.
@@ -367,6 +375,12 @@ def testUtf8InputString(self):
367375
self.assertEqual(create('x', u'\u03b4'.encode('utf-8')).to_string(),
368376
'<x>&#948;</x>')
369377

378+
def testUtf8TagsAndAttributes(self):
379+
self.assertEqual(
380+
parse(u'<\u03b4elta>test</\u03b4elta>'.encode('utf-8'))._qname,
381+
u'\u03b4elta')
382+
self.assertEqual(parse('<\xce\xb4elta>test</\xce\xb4elta>')._qname,
383+
u'\u03b4elta')
370384

371385

372386
def testOtherEncodingOnInputString(self):
@@ -387,7 +401,11 @@ def testOtherEncodingOnInputString(self):
387401
self.assertEqual(
388402
create('x', '\xff\xfe\xb4\x03').to_string(encoding='utf-16'),
389403
'<x>&#948;</x>')
390-
404+
405+
def testOtherEncodingInTagsAndAttributes(self):
406+
self.assertEqual(
407+
parse(u'<\u03b4elta>test</\u03b4elta>'.encode('utf-16'))._qname,
408+
u'\u03b4elta')
391409

392410

393411
def suite():

0 commit comments

Comments
 (0)