summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-03-22 16:07:38 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-03-22 16:07:38 (GMT)
commit9e7a4c9738cffe785156b46c02148b890530ef14 (patch)
treec4fd377ac46cd710311ad1a5d2a74323a4927e1e /Lib
parentc9d1a7845ba18466ee048666239c6b969c9acd33 (diff)
downloadcpython-9e7a4c9738cffe785156b46c02148b890530ef14.zip
cpython-9e7a4c9738cffe785156b46c02148b890530ef14.tar.gz
cpython-9e7a4c9738cffe785156b46c02148b890530ef14.tar.bz2
Issue #7703: ctypes supports both buffer() and memoryview(). The former is deprecated.
Complement of r79288.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/ctypes/test/test_strings.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index 324848e..8945d0c 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -1,5 +1,6 @@
import unittest
from ctypes import *
+from test import test_support
class StringArrayTestCase(unittest.TestCase):
def test(self):
@@ -24,7 +25,7 @@ class StringArrayTestCase(unittest.TestCase):
self.assertRaises(ValueError, setattr, buf, "value", "aaaaaaaa")
self.assertRaises(TypeError, setattr, buf, "value", 42)
- def test_c_buffer_value(self):
+ def test_c_buffer_value(self, memoryview=memoryview):
buf = c_buffer(32)
buf.value = "Hello, World"
@@ -34,7 +35,7 @@ class StringArrayTestCase(unittest.TestCase):
self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
- def test_c_buffer_raw(self):
+ def test_c_buffer_raw(self, memoryview=memoryview):
buf = c_buffer(32)
buf.raw = memoryview("Hello, World")
@@ -42,6 +43,12 @@ class StringArrayTestCase(unittest.TestCase):
self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
+ def test_c_buffer_deprecated(self):
+ # Compatibility with 2.x
+ with test_support.check_py3k_warnings():
+ self.test_c_buffer_value(buffer)
+ self.test_c_buffer_raw(buffer)
+
def test_param_1(self):
BUF = c_char * 4
buf = BUF()