summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_buffer.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_buffer.py')
-rwxr-xr-x[-rw-r--r--]Lib/test/test_buffer.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
index 47413c0..5fa52bf 100644..100755
--- a/Lib/test/test_buffer.py
+++ b/Lib/test/test_buffer.py
@@ -43,6 +43,11 @@ try:
except ImportError:
numpy_array = None
+try:
+ import _testcapi
+except ImportError:
+ _testcapi = None
+
SHORT_TEST = True
@@ -4412,6 +4417,13 @@ class TestBufferProtocol(unittest.TestCase):
x = ndarray([1,2,3], shape=[3], flags=ND_GETBUF_FAIL)
self.assertRaises(BufferError, memoryview, x)
+ @support.cpython_only
+ def test_pybuffer_size_from_format(self):
+ # basic tests
+ for format in ('', 'ii', '3s'):
+ self.assertEqual(_testcapi.PyBuffer_SizeFromFormat(format),
+ struct.calcsize(format))
+
if __name__ == "__main__":
unittest.main()