diff options
author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-02-17 13:17:26 (GMT) |
---|---|---|
committer | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-02-17 13:17:26 (GMT) |
commit | 17a837e4dba610d87409c3ed532d30aa68502108 (patch) | |
tree | c7cf1bb4a0f9bccc355a8abc2a0d14e807248688 /Lib/test/test_mmap.py | |
parent | 1d0b5cc6dcbabc217242ca5e141c900200ad4c26 (diff) | |
download | cpython-17a837e4dba610d87409c3ed532d30aa68502108.zip cpython-17a837e4dba610d87409c3ed532d30aa68502108.tar.gz cpython-17a837e4dba610d87409c3ed532d30aa68502108.tar.bz2 |
Issue #5282: Fixed mmap resize on 32bit windows and unix. When offset > 0,
The file was resized to wrong size.
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 e1e5967..c06b757 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: |