summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bytes.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2007-10-08 02:46:15 (GMT)
committerGuido van Rossum <guido@python.org>2007-10-08 02:46:15 (GMT)
commitbae07c9baf3e53164de6f85a18ce747a76b9ffde (patch)
treee0bf84063848730026bea64461fe3920dbe8ecb8 /Lib/test/test_bytes.py
parent85c1ba5d742779eec3148377ce6d8d359d318263 (diff)
downloadcpython-bae07c9baf3e53164de6f85a18ce747a76b9ffde.zip
cpython-bae07c9baf3e53164de6f85a18ce747a76b9ffde.tar.gz
cpython-bae07c9baf3e53164de6f85a18ce747a76b9ffde.tar.bz2
Breaking ground for PEP 3137 implementation:
Get rid of buffer(). Use memoryview() in its place where possible. In a few places, do things a bit different, because memoryview() can't slice (yet).
Diffstat (limited to 'Lib/test/test_bytes.py')
-rw-r--r--Lib/test/test_bytes.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index cfcd282..61950cc 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -343,7 +343,7 @@ class BytesTest(unittest.TestCase):
def test_from_buffer(self):
sample = str8("Hello world\n\x80\x81\xfe\xff")
- buf = buffer(sample)
+ buf = memoryview(sample)
b = bytes(buf)
self.assertEqual(b, bytes(map(ord, sample)))
@@ -456,8 +456,8 @@ class BytesTest(unittest.TestCase):
b = bytes([0x1a, 0x2b, 0x30])
self.assertEquals(bytes.fromhex('1a2B30'), b)
self.assertEquals(bytes.fromhex(' 1A 2B 30 '), b)
- self.assertEquals(bytes.fromhex(buffer(b'')), bytes())
- self.assertEquals(bytes.fromhex(buffer(b'0000')), bytes([0, 0]))
+ self.assertEquals(bytes.fromhex(memoryview(b'')), bytes())
+ self.assertEquals(bytes.fromhex(memoryview(b'0000')), bytes([0, 0]))
self.assertRaises(ValueError, bytes.fromhex, 'a')
self.assertRaises(ValueError, bytes.fromhex, 'rt')
self.assertRaises(ValueError, bytes.fromhex, '1a b cd')
@@ -630,7 +630,7 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b' a bb c '.split(None, 3), [b'a', b'bb', b'c'])
def test_split_buffer(self):
- self.assertEqual(b'a b'.split(buffer(b' ')), [b'a', b'b'])
+ self.assertEqual(b'a b'.split(memoryview(b' ')), [b'a', b'b'])
def test_split_string_error(self):
self.assertRaises(TypeError, b'a b'.split, ' ')
@@ -653,7 +653,7 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b' a bb c '.rsplit(None, 3), [b'a', b'bb', b'c'])
def test_rplit_buffer(self):
- self.assertEqual(b'a b'.rsplit(buffer(b' ')), [b'a', b'b'])
+ self.assertEqual(b'a b'.rsplit(memoryview(b' ')), [b'a', b'b'])
def test_rplit_string_error(self):
self.assertRaises(TypeError, b'a b'.rsplit, ' ')
@@ -707,9 +707,9 @@ class BytesTest(unittest.TestCase):
self.assertEqual(b.rstrip(), b' \t\n\r\f\vabc')
def test_strip_buffer(self):
- self.assertEqual(b'abc'.strip(buffer(b'ac')), b'b')
- self.assertEqual(b'abc'.lstrip(buffer(b'ac')), b'bc')
- self.assertEqual(b'abc'.rstrip(buffer(b'ac')), b'ab')
+ self.assertEqual(b'abc'.strip(memoryview(b'ac')), b'b')
+ self.assertEqual(b'abc'.lstrip(memoryview(b'ac')), b'bc')
+ self.assertEqual(b'abc'.rstrip(memoryview(b'ac')), b'ab')
def test_strip_string_error(self):
self.assertRaises(TypeError, b'abc'.strip, 'b')