mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-33176: Add a toreadonly() method to memoryviews. (GH-6466)
This commit is contained in:
parent
b1dc07509f
commit
480ab05d5f
5 changed files with 72 additions and 15 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue