[pypy-commit] pypy py3.5: Test behaviour of lone surrogates with non-default error handlers

rlamy pypy.commits at gmail.com
Mon Oct 9 19:54:27 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r92692:86bb8174a0e9
Date: 2017-10-10 01:53 +0200
http://bitbucket.org/pypy/pypy/changeset/86bb8174a0e9/

Log:	Test behaviour of lone surrogates with non-default error handlers

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
@@ -762,9 +762,16 @@
         assert s == b'\xe9'
 
     def test_lone_surrogates(self):
-        for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
-                         'utf-32', 'utf-32-le', 'utf-32-be'):
+        encodings = ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
+            'utf-32', 'utf-32-le', 'utf-32-be')
+        for encoding in encodings:
             raises(UnicodeEncodeError, u'\ud800'.encode, encoding)
+            assert (u'[\udc80]'.encode(encoding, "backslashreplace") ==
+                '[\\udc80]'.encode(encoding))
+            assert (u'[\udc80]'.encode(encoding, "ignore") ==
+                '[]'.encode(encoding))
+            assert (u'[\udc80]'.encode(encoding, "replace") ==
+                '[?]'.encode(encoding))
 
     def test_charmap_encode(self):
         assert 'xxx'.encode('charmap') == b'xxx'


More information about the pypy-commit mailing list