Line
Link Here
|
0 |
-- tests/atom_tests/core_test.py |
0 |
++ tests/atom_tests/core_test.py |
Lines 398-403
Link Here
|
398 |
self.assertTrue(x.to_string().startswith('<x a="δ"')) |
398 |
self.assertTrue(x.to_string().startswith('<x a="δ"')) |
399 |
|
399 |
|
400 |
def testOtherEncodingOnInputString(self): |
400 |
def testOtherEncodingOnInputString(self): |
|
|
401 |
BIG_ENDIAN = 0 |
402 |
LITTLE_ENDIAN = 1 |
401 |
# Test parsing inner text. |
403 |
# Test parsing inner text. |
402 |
self.assertEqual(parse(u'<x>\u03b4</x>'.encode('utf-16')).text, u'\u03b4') |
404 |
self.assertEqual(parse(u'<x>\u03b4</x>'.encode('utf-16')).text, u'\u03b4') |
403 |
|
405 |
|
Lines 409-420
Link Here
|
409 |
e = create('x', u'\u03b4'.encode('utf-16')) |
411 |
e = create('x', u'\u03b4'.encode('utf-16')) |
410 |
self.assertEqual(e.to_string(encoding='utf-16'), '<x>δ</x>') |
412 |
self.assertEqual(e.to_string(encoding='utf-16'), '<x>δ</x>') |
411 |
# Don't change the encoding until the we convert to an XML string. |
413 |
# Don't change the encoding until the we convert to an XML string. |
412 |
self.assertEqual(e.text, '\xff\xfe\xb4\x03') |
414 |
# Allow either little-endian or big-endian byte orderings. |
|
|
415 |
self.assertTrue(e.text in ['\xff\xfe\xb4\x03', '\xfe\xff\x03\xb4']) |
416 |
endianness = LITTLE_ENDIAN |
417 |
if e.text == '\xfe\xff\x03\xb4': |
418 |
endianness = BIG_ENDIAN |
413 |
self.assertTrue(isinstance(e.text, str)) |
419 |
self.assertTrue(isinstance(e.text, str)) |
414 |
self.assertTrue(isinstance(e.to_string(encoding='utf-16'), str)) |
420 |
self.assertTrue(isinstance(e.to_string(encoding='utf-16'), str)) |
415 |
self.assertEqual( |
421 |
if endianness == LITTLE_ENDIAN: |
416 |
create('x', '\xff\xfe\xb4\x03').to_string(encoding='utf-16'), |
422 |
self.assertEqual( |
417 |
'<x>δ</x>') |
423 |
create('x', '\xff\xfe\xb4\x03').to_string(encoding='utf-16'), |
|
|
424 |
'<x>δ</x>') |
425 |
else: |
426 |
self.assertEqual( |
427 |
create('x', '\xfe\xff\x03\xb4').to_string(encoding='utf-16'), |
428 |
'<x>δ</x>') |
418 |
|
429 |
|
419 |
def testOtherEncodingInTagsAndAttributes(self): |
430 |
def testOtherEncodingInTagsAndAttributes(self): |
420 |
self.assertEqual( |
431 |
self.assertEqual( |