mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-111835: Add seekable method to mmap.mmap (gh-111852)
This commit is contained in:
parent
30ec968bef
commit
6046aec377
5 changed files with 40 additions and 12 deletions
|
@ -93,11 +93,12 @@ class MmapTests(unittest.TestCase):
|
|||
self.assertEqual(end, PAGESIZE + 6)
|
||||
|
||||
# test seeking around (try to overflow the seek implementation)
|
||||
m.seek(0,0)
|
||||
self.assertTrue(m.seekable())
|
||||
self.assertEqual(m.seek(0, 0), 0)
|
||||
self.assertEqual(m.tell(), 0)
|
||||
m.seek(42,1)
|
||||
self.assertEqual(m.seek(42, 1), 42)
|
||||
self.assertEqual(m.tell(), 42)
|
||||
m.seek(0,2)
|
||||
self.assertEqual(m.seek(0, 2), len(m))
|
||||
self.assertEqual(m.tell(), len(m))
|
||||
|
||||
# Try to seek to negative position...
|
||||
|
@ -162,7 +163,7 @@ class MmapTests(unittest.TestCase):
|
|||
|
||||
# Ensuring that readonly mmap can't be write() to
|
||||
try:
|
||||
m.seek(0,0)
|
||||
m.seek(0, 0)
|
||||
m.write(b'abc')
|
||||
except TypeError:
|
||||
pass
|
||||
|
@ -171,7 +172,7 @@ class MmapTests(unittest.TestCase):
|
|||
|
||||
# Ensuring that readonly mmap can't be write_byte() to
|
||||
try:
|
||||
m.seek(0,0)
|
||||
m.seek(0, 0)
|
||||
m.write_byte(b'd')
|
||||
except TypeError:
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue