Commits

Manuel Jacob committed eb20b02

Port implementation-dependent skips in test_bytes from 2.7 test suite to 3.2.

Comments (0)

Files changed (1)

lib-python/3.2/test/test_bytes.py

         self.assertEqual(b, b1)
         self.assertTrue(b is b1)
 
+    @test.support.impl_detail("undocumented bytes.__alloc__()")
     def test_alloc(self):
         b = bytearray()
         alloc = b.__alloc__()
         self.assertEqual(b, b"")
         self.assertEqual(c, b"")
 
+    @test.support.impl_detail(
+        "resizing semantics of CPython rely on refcounting")
     def test_resize_forbidden(self):
         # #4509: can't resize a bytearray when there are buffer exports, even
         # if it wouldn't reallocate the underlying buffer.
         self.assertRaises(BufferError, delslice)
         self.assertEqual(b, orig)
 
+    @test.support.impl_detail("resizing semantics", cpython=False)
+    def test_resize_forbidden_non_cpython(self):
+        # on non-CPython implementations, we cannot prevent changes to
+        # bytearrays just because there are buffers around.  Instead,
+        # we get (on PyPy) a buffer that follows the changes and resizes.
+        b = bytearray(range(10))
+        for v in [memoryview(b), buffer(b)]:
+            b[5] = 99
+            self.assertIn(v[5], (99, chr(99)))
+            b[5] = 100
+            b += b
+            b += b
+            b += b
+            self.assertEquals(len(v), 80)
+            self.assertIn(v[5], (100, chr(100)))
+            self.assertIn(v[79], (9, chr(9)))
+            del b[10:]
+            self.assertRaises(IndexError, lambda: v[10])
+            self.assertEquals(len(v), 10)
+
 
 class AssortedBytesTest(unittest.TestCase):
     #