summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_memoryview.py
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2018-04-14 17:49:21 (GMT)
committerGitHub <noreply@github.com>2018-04-14 17:49:21 (GMT)
commit480ab05d5fee2b8fa161f799af33086a4e68c7dd (patch)
treeca45c39193fb970c4d300b27346a9dcf8aaac814 /Lib/test/test_memoryview.py
parentb1dc07509f78b354e83f5f4a902f1ff80c7bb05d (diff)
downloadcpython-480ab05d5fee2b8fa161f799af33086a4e68c7dd.zip
cpython-480ab05d5fee2b8fa161f799af33086a4e68c7dd.tar.gz
cpython-480ab05d5fee2b8fa161f799af33086a4e68c7dd.tar.bz2
bpo-33176: Add a toreadonly() method to memoryviews. (GH-6466)
Diffstat (limited to 'Lib/test/test_memoryview.py')
-rw-r--r--Lib/test/test_memoryview.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index ddd5b9a..ca307d8 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -362,6 +362,17 @@ class AbstractMemoryTests:
self.assertEqual(list(reversed(m)), aslist)
self.assertEqual(list(reversed(m)), list(m[::-1]))
+ def test_toreadonly(self):
+ for tp in self._types:
+ b = tp(self._source)
+ m = self._view(b)
+ mm = m.toreadonly()
+ self.assertTrue(mm.readonly)
+ self.assertTrue(memoryview(mm).readonly)
+ self.assertEqual(mm.tolist(), m.tolist())
+ mm.release()
+ m.tolist()
+
def test_issue22668(self):
a = array.array('H', [256, 256, 256, 256])
x = memoryview(a)