Author: [email protected]
Branch:
Changeset: r96996:961477b88452
Date: 2019-07-14 12:40 +0200
http://bitbucket.org/pypy/pypy/changeset/961477b88452/
Log: fix test_unicode_outofrange in case itemsize == 2
diff --git a/pypy/module/array/test/test_array.py
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -860,16 +860,22 @@
b.byteswap()
assert b[2] == u'\u0000'
assert a != b
- e = raises(ValueError, "b[0]") # doesn't work
- assert str(e.value) == (
- "cannot operate on this array('u') because it contains"
- " character U+1000000 not in range [U+0000; U+10ffff]"
- " at index 0")
+ if b.itemsize == 4:
+ e = raises(ValueError, "b[0]") # doesn't work
+ assert str(e.value) == (
+ "cannot operate on this array('u') because it contains"
+ " character U+1000000 not in range [U+0000; U+10ffff]"
+ " at index 0")
+ assert str(b) == ("array('u', <character U+1000000 is not in"
+ " range [U+0000; U+10ffff]>)")
+ raises(ValueError, b.tounicode) # doesn't work
+ elif b.itemsize == 2:
+ assert b[0] == u'\u0100'
+ byteswaped_unicode = u'\u0100\u3a26\x00\ufffe'
+ assert str(b) == "array('u', %r)" % (byteswaped_unicode,)
+ assert b.tounicode() == byteswaped_unicode
assert str(a) == "array('u', %r)" % (input_unicode,)
- assert str(b) == ("array('u', <character U+1000000 is not in"
- " range [U+0000; U+10ffff]>)")
assert a.tounicode() == input_unicode
- raises(ValueError, b.tounicode) # doesn't work
def test_unicode_surrogate(self):
a = self.array('u', u'\ud800')
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit