diff options
Diffstat (limited to 'Lib/test/test_buffer.py')
-rw-r--r-- | Lib/test/test_buffer.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py index 761ed0a..47413c0 100644 --- a/Lib/test/test_buffer.py +++ b/Lib/test/test_buffer.py @@ -893,6 +893,15 @@ class TestBufferProtocol(unittest.TestCase): y = ndarray(initlst, shape=shape, flags=ro, format=fmt) self.assertEqual(memoryview(y), memoryview(result)) + contig_bytes = memoryview(result).tobytes() + self.assertEqual(contig_bytes, contig) + + contig_bytes = memoryview(result).tobytes(order=None) + self.assertEqual(contig_bytes, contig) + + contig_bytes = memoryview(result).tobytes(order='C') + self.assertEqual(contig_bytes, contig) + # To 'F' contig = py_buffer_to_contiguous(result, 'F', PyBUF_FULL_RO) self.assertEqual(len(contig), nmemb * itemsize) @@ -905,6 +914,9 @@ class TestBufferProtocol(unittest.TestCase): format=fmt) self.assertEqual(memoryview(y), memoryview(result)) + contig_bytes = memoryview(result).tobytes(order='F') + self.assertEqual(contig_bytes, contig) + # To 'A' contig = py_buffer_to_contiguous(result, 'A', PyBUF_FULL_RO) self.assertEqual(len(contig), nmemb * itemsize) @@ -917,6 +929,9 @@ class TestBufferProtocol(unittest.TestCase): y = ndarray(initlst, shape=shape, flags=f|ro, format=fmt) self.assertEqual(memoryview(y), memoryview(result)) + contig_bytes = memoryview(result).tobytes(order='A') + self.assertEqual(contig_bytes, contig) + if is_memoryview_format(fmt): try: m = memoryview(result) |