[pypy-commit] pypy unicode-utf8-py3: fix tests for python3

mattip pypy.commits at gmail.com
Tue Jan 15 18:18:22 EST 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: unicode-utf8-py3
Changeset: r95639:ef1027524c11
Date: 2019-01-15 16:35 +0200
http://bitbucket.org/pypy/pypy/changeset/ef1027524c11/

Log:	fix tests for python3

diff --git a/pypy/module/_io/test/test_interp_textio.py b/pypy/module/_io/test/test_interp_textio.py
--- a/pypy/module/_io/test/test_interp_textio.py
+++ b/pypy/module/_io/test/test_interp_textio.py
@@ -58,17 +58,17 @@
 
 @given(st.text())
 def test_read_buffer(text):
-    buf = DecodeBuffer(text)
-    assert buf.get_chars(-1) == text
+    buf = DecodeBuffer(text.encode('utf8'))
+    assert buf.get_chars(-1).decode('utf8') == text
     assert buf.exhausted()
 
 @given(st.text(), st.lists(st.integers(min_value=0)))
 @example(u'\x80', [1])
 def test_readn_buffer(text, sizes):
-    buf = DecodeBuffer(text)
+    buf = DecodeBuffer(text.encode('utf8'))
     strings = []
     for n in sizes:
-        s = buf.get_chars(n)
+        s = buf.get_chars(n).decode('utf8')
         if not buf.exhausted():
             assert len(s) == n
         else:
@@ -79,11 +79,11 @@
 @given(st.text())
 @example(u'\x800')
 def test_next_char(text):
-    buf = DecodeBuffer(text)
+    buf = DecodeBuffer(text.encode('utf8'))
     chars = []
     try:
         while True:
-            ch = buf.next_char()
+            ch = buf.next_char().decode('utf8')
             chars.append(ch)
     except StopIteration:
         pass
diff --git a/pypy/objspace/std/test/test_unicodeobject.py b/pypy/objspace/std/test/test_unicodeobject.py
--- a/pypy/objspace/std/test/test_unicodeobject.py
+++ b/pypy/objspace/std/test/test_unicodeobject.py
@@ -338,8 +338,8 @@
         assert u'A\u03a3A'.title() == u'A\u03c3a'
         assert u"brow\u4321n fox".title() == u"Brow\u4321N Fox"
         assert u'\ud800'.title() == u'\ud800'
-        assert (unichr(0x345) + u'abc').title() == u'\u0399Abc'
-        assert (unichr(0x345) + u'ABC').title() == u'\u0399Abc'
+        assert (chr(0x345) + u'abc').title() == u'\u0399abc'
+        assert (chr(0x345) + u'ABC').title() == u'\u0399abc'
 
     def test_istitle(self):
         assert u"".istitle() == False


More information about the pypy-commit mailing list