[pypy-commit] pypy py3k: Fix most tests in module/__pypy__

amauryfa noreply at buildbot.pypy.org
Tue Feb 7 23:53:16 CET 2012


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: py3k
Changeset: r52209:0a4739cd0f36
Date: 2012-02-07 23:47 +0100
http://bitbucket.org/pypy/pypy/changeset/0a4739cd0f36/

Log:	Fix most tests in module/__pypy__

diff --git a/pypy/module/__pypy__/interp_builders.py b/pypy/module/__pypy__/interp_builders.py
--- a/pypy/module/__pypy__/interp_builders.py
+++ b/pypy/module/__pypy__/interp_builders.py
@@ -38,9 +38,12 @@
 
         def descr_build(self, space):
             self._check_done(space)
-            w_s = space.wrap(self.builder.build())
+            s = self.builder.build()
             self.builder = None
-            return w_s
+            if strtype is str:
+                return space.wrapbytes(s)
+            else:
+                return space.wrap(s)
 
         def descr_len(self, space):
             if self.builder is None:
diff --git a/pypy/module/__pypy__/test/test_builders.py b/pypy/module/__pypy__/test/test_builders.py
--- a/pypy/module/__pypy__/test/test_builders.py
+++ b/pypy/module/__pypy__/test/test_builders.py
@@ -8,39 +8,39 @@
     def test_simple(self):
         from __pypy__.builders import UnicodeBuilder
         b = UnicodeBuilder()
-        b.append(u"abc")
-        b.append(u"123")
-        b.append(u"1")
+        b.append("abc")
+        b.append("123")
+        b.append("1")
         s = b.build()
-        assert s == u"abc1231"
+        assert s == "abc1231"
         raises(ValueError, b.build)
-        raises(ValueError, b.append, u"123")
+        raises(ValueError, b.append, "123")
 
     def test_preallocate(self):
         from __pypy__.builders import UnicodeBuilder
         b = UnicodeBuilder(10)
-        b.append(u"abc")
-        b.append(u"123")
+        b.append("abc")
+        b.append("123")
         s = b.build()
-        assert s == u"abc123"
+        assert s == "abc123"
 
     def test_append_slice(self):
         from __pypy__.builders import UnicodeBuilder
         b = UnicodeBuilder()
-        b.append_slice(u"abcdefgh", 2, 5)
-        raises(ValueError, b.append_slice, u"1", 2, 1)
+        b.append_slice("abcdefgh", 2, 5)
+        raises(ValueError, b.append_slice, "1", 2, 1)
         s = b.build()
         assert s == "cde"
-        raises(ValueError, b.append_slice, u"abc", 1, 2)
+        raises(ValueError, b.append_slice, "abc", 1, 2)
 
     def test_stringbuilder(self):
         from __pypy__.builders import StringBuilder
         b = StringBuilder()
-        b.append("abc")
-        b.append("123")
+        b.append(b"abc")
+        b.append(b"123")
         assert len(b) == 6
-        b.append("you and me")
+        b.append(b"you and me")
         s = b.build()
         raises(ValueError, len, b)
-        assert s == "abc123you and me"
+        assert s == b"abc123you and me"
         raises(ValueError, b.build)
diff --git a/pypy/module/__pypy__/test/test_bytebuffer.py b/pypy/module/__pypy__/test/test_bytebuffer.py
--- a/pypy/module/__pypy__/test/test_bytebuffer.py
+++ b/pypy/module/__pypy__/test/test_bytebuffer.py
@@ -10,10 +10,10 @@
         b = bytebuffer(12)
         assert isinstance(b, buffer)
         assert len(b) == 12
-        b[3] = '!'
-        b[5] = '?'
-        assert b[2:7] == '\x00!\x00?\x00'
-        b[9:] = '+-*'
-        assert b[-1] == '*'
-        assert b[-2] == '-'
-        assert b[-3] == '+'
+        b[3] = b'!'
+        b[5] = b'?'
+        assert b[2:7] == b'\x00!\x00?\x00'
+        b[9:] = b'+-*'
+        assert b[-1] == b'*'
+        assert b[-2] == b'-'
+        assert b[-3] == b'+'
diff --git a/pypy/module/__pypy__/test/test_identitydict.py b/pypy/module/__pypy__/test/test_identitydict.py
--- a/pypy/module/__pypy__/test/test_identitydict.py
+++ b/pypy/module/__pypy__/test/test_identitydict.py
@@ -10,10 +10,9 @@
         d = identity_dict()
         d[0] = 1
         d[0.0] = 2
-        d[long(0)] = 3
 
         assert d
-        assert len(d) == 3
+        assert len(d) == 2
         del d[0]
         d.clear()
         assert not d
diff --git a/pypy/module/__pypy__/test/test_special.py b/pypy/module/__pypy__/test/test_special.py
--- a/pypy/module/__pypy__/test/test_special.py
+++ b/pypy/module/__pypy__/test/test_special.py
@@ -5,7 +5,7 @@
     def setup_class(cls):
         if option.runappdirect:
             py.test.skip("does not make sense on pypy-c")
-        cls.space = gettestobjspace(**{"objspace.usemodules.select": False, "objspace.std.withrangelist": True})
+        cls.space = gettestobjspace(**{"objspace.usemodules.select": False})
 
     def test__isfake(self):
         from __pypy__ import isfake
@@ -32,9 +32,9 @@
         assert my.b() == ()
         assert A.a(my) == (my,)
         assert A.b(my) == (my,)
-        assert A.a.im_func(my) == (my,)
+        assert not hasattr(A.a, 'im_func')
         assert not hasattr(A.b, 'im_func')
-        assert A.a is not A.__dict__['a']
+        assert A.a is A.__dict__['a']
         assert A.b is A.__dict__['b']
 
     def test_lookup_special(self):


More information about the pypy-commit mailing list