Author: Stefano Rivera <[email protected]>
Branch:
Changeset: r51313:c6a06cbab53d
Date: 2012-01-14 21:07 +0200
http://bitbucket.org/pypy/pypy/changeset/c6a06cbab53d/
Log: Big endian test case for test_utf_16_encode_decode
diff --git a/pypy/module/_codecs/test/test_codecs.py
b/pypy/module/_codecs/test/test_codecs.py
--- a/pypy/module/_codecs/test/test_codecs.py
+++ b/pypy/module/_codecs/test/test_codecs.py
@@ -588,10 +588,18 @@
raises(UnicodeDecodeError, '+3ADYAA-'.decode, 'utf-7')
def test_utf_16_encode_decode(self):
- import codecs
+ import codecs, sys
x = u'123abc'
- assert codecs.getencoder('utf-16')(x) ==
('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00', 6)
- assert
codecs.getdecoder('utf-16')('\xff\xfe1\x002\x003\x00a\x00b\x00c\x00') == (x, 14)
+ if sys.byteorder == 'big':
+ assert codecs.getencoder('utf-16')(x) == (
+ '\xfe\xff\x001\x002\x003\x00a\x00b\x00c', 6)
+ assert codecs.getdecoder('utf-16')(
+ '\xfe\xff\x001\x002\x003\x00a\x00b\x00c') == (x, 14)
+ else:
+ assert codecs.getencoder('utf-16')(x) == (
+ '\xff\xfe1\x002\x003\x00a\x00b\x00c\x00', 6)
+ assert codecs.getdecoder('utf-16')(
+ '\xff\xfe1\x002\x003\x00a\x00b\x00c\x00') == (x, 14)
def test_unicode_escape(self):
assert u'\\'.encode('unicode-escape') == '\\\\'
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit