Commits

Amaury Forgeot d'Arc  committed 0a4739c

Fix most tests in module/__pypy__

  • Participants
  • Parent commits e86aec0
  • Branches py3k

Comments (0)

Files changed (5)

File pypy/module/__pypy__/interp_builders.py

 
         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:

File pypy/module/__pypy__/test/test_builders.py

     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)

File pypy/module/__pypy__/test/test_bytebuffer.py

         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'+'

File pypy/module/__pypy__/test/test_identitydict.py

         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

File pypy/module/__pypy__/test/test_special.py

     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
         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):