summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorKristján Valur Jónsson <sweskman@gmail.com>2013-03-20 00:17:47 (GMT)
committerKristján Valur Jónsson <sweskman@gmail.com>2013-03-20 00:17:47 (GMT)
commit9795ca44fbf6d94789ee7053b81ff18f008c41ea (patch)
tree0aa7878e2ea987a574f5d9ad4090c0a0f8f0437d /Lib
parent1d108bc7148336f01d6df066ba1b27678c9bd1ca (diff)
downloadcpython-9795ca44fbf6d94789ee7053b81ff18f008c41ea.zip
cpython-9795ca44fbf6d94789ee7053b81ff18f008c41ea.tar.gz
cpython-9795ca44fbf6d94789ee7053b81ff18f008c41ea.tar.bz2
Issue #10212: Support new buffer interface for struct.unpack and
cStringIO
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_StringIO.py5
-rw-r--r--Lib/test/test_struct.py11
2 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py
index 37a825f..42f307a 100644
--- a/Lib/test/test_StringIO.py
+++ b/Lib/test/test_StringIO.py
@@ -20,7 +20,6 @@ class TestGenericStringIO(unittest.TestCase):
constructor = str
def setUp(self):
- self._line = self.constructor(self._line)
self._lines = self.constructor((self._line + '\n') * 5)
self._fp = self.MODULE.StringIO(self._lines)
@@ -210,12 +209,16 @@ class TestBufferStringIO(TestStringIO):
class TestBuffercStringIO(TestcStringIO):
constructor = buffer
+class TestMemoryviewcStringIO(TestcStringIO):
+ constructor = memoryview
+
def test_main():
test_support.run_unittest(TestStringIO, TestcStringIO)
with test_support.check_py3k_warnings(("buffer.. not supported",
DeprecationWarning)):
test_support.run_unittest(TestBufferStringIO, TestBuffercStringIO)
+ test_support.run_unittest(TestMemoryviewcStringIO)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index c8dc6f1..f1b5d9a 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -496,6 +496,17 @@ class StructTest(unittest.TestCase):
self.test_unpack_from(cls=buffer)
+ def test_unpack_with_memoryview(self):
+ with check_py3k_warnings(("buffer.. not supported in 3.x",
+ DeprecationWarning)):
+ # SF bug 1563759: struct.unpack doesn't support buffer protocol objects
+ data1 = memoryview('\x12\x34\x56\x78')
+ for data in [data1,]:
+ value, = struct.unpack('>I', data)
+ self.assertEqual(value, 0x12345678)
+
+ self.test_unpack_from(cls=memoryview)
+
def test_bool(self):
class ExplodingBool(object):
def __nonzero__(self):