[pypy-commit] pypy rpython-utf8: improve the test by actually using strings which are encodable only by the tested encodings

antocuni noreply at buildbot.pypy.org
Thu Aug 30 16:24:59 CEST 2012


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: rpython-utf8
Changeset: r56942:f285edd50f55
Date: 2012-08-30 16:09 +0200
http://bitbucket.org/pypy/pypy/changeset/f285edd50f55/

Log:	improve the test by actually using strings which are encodable only
	by the tested encodings

diff --git a/pypy/rpython/test/test_runicode.py b/pypy/rpython/test/test_runicode.py
--- a/pypy/rpython/test/test_runicode.py
+++ b/pypy/rpython/test/test_runicode.py
@@ -98,9 +98,11 @@
         self.interpret_raises(UnicodeEncodeError, f, [1234])
 
     def test_unicode_encode(self):
-        def f(x):
-            y = u'xxx'
-            return (y + unichr(x)).encode('ascii') + y.encode('latin-1') + y.encode('utf-8')
+        def f(n):
+            x = u'xxx' + unichr(n)
+            y = u'&#224;&#232;&#236;' + unichr(n)
+            z = u'&#32654;' + unichr(n)
+            return x.encode('ascii') + y.encode('latin-1') + z.encode('utf-8')
 
         assert self.ll_to_string(self.interpret(f, [38])) == f(38)
 


More information about the pypy-commit mailing list