diff options
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r-- | Lib/test/test_mmap.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index e1e59670c6..c06b7579cc 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -417,6 +417,27 @@ class MmapTests(unittest.TestCase): m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize) self.assertEqual(m[0:3], 'foo') f.close() + + # Try resizing map + try: + m.resize(512) + except SystemError: + pass + else: + # resize() is supported + self.assertEqual(len(m), 512) + # Check that we can no longer seek beyond the new size. + self.assertRaises(ValueError, m.seek, 513, 0) + # Check that the content is not changed + self.assertEqual(m[0:3], 'foo') + + # Check that the underlying file is truncated too + f = open(TESTFN) + f.seek(0, 2) + self.assertEqual(f.tell(), halfsize + 512) + f.close() + self.assertEqual(m.size(), halfsize + 512) + m.close() finally: |