Author: Manuel Jacob
Branch: py3k
Changeset: r61198:eb20b02bd057
Date: 2013-02-12 17:13 +0100
http://bitbucket.org/pypy/pypy/changeset/eb20b02bd057/
Log: Port implementation-dependent skips in test_bytes from 2.7 test
suite to 3.2.
diff --git a/lib-python/3.2/test/test_bytes.py
b/lib-python/3.2/test/test_bytes.py
--- a/lib-python/3.2/test/test_bytes.py
+++ b/lib-python/3.2/test/test_bytes.py
@@ -764,6 +764,7 @@
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__()
@@ -890,6 +891,8 @@
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.
@@ -922,6 +925,26 @@
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):
#
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit