diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-09-10 20:49:15 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-09-10 20:49:15 (GMT) |
commit | 4f4f4d70af3197cfedb41ae62eab37f3dc52e11a (patch) | |
tree | 467551742c79bc6f67687cbb76ed90fd2d0e3a5b /Lib | |
parent | a0d183363971887a29d176d52c35275eb9a014f0 (diff) | |
download | cpython-4f4f4d70af3197cfedb41ae62eab37f3dc52e11a.zip cpython-4f4f4d70af3197cfedb41ae62eab37f3dc52e11a.tar.gz cpython-4f4f4d70af3197cfedb41ae62eab37f3dc52e11a.tar.bz2 |
A few days ago a test was added here to ensure that creating an mmap
with a size larger than the underlying file worked on Windows. It
does <wink>. However, merely creating an mmap that way has the side
effect of growing the file on disk to match the specified size. A
*later* test assumed that the file on disk was still exactly as it was
before the new "size too big" test was added, but that's no longer true.
So added a hack at the end of the "size too big" test to truncate the
disk file back to its original size on Windows.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_mmap.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 3322c38..26dbc4a 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -102,7 +102,7 @@ def test_both(): # Try resizing map print ' Attempting resize()' try: - m.resize( 512 ) + m.resize(512) except SystemError: # resize() not supported # No messages are printed, since the output of this test suite @@ -196,14 +196,22 @@ def test_both(): m = mmap.mmap(f.fileno(), mapsize+1) except ValueError: # we do not expect a ValueError on Windows + # CAUTION: This also changes the size of the file on disk, and + # later tests assume that the length hasn't changed. We need to + # repair that. if sys.platform.startswith('win'): verify(0, "Opening mmap with size+1 should work on Windows.") else: # we expect a ValueError on Unix, but not on Windows if not sys.platform.startswith('win'): verify(0, "Opening mmap with size+1 should raise ValueError.") - del m - del f + m.close() + f.close() + if sys.platform.startswith('win'): + # Repair damage from the resizing test. + f = open(TESTFN, 'r+b') + f.truncate(mapsize) + f.close() print " Opening mmap with access=ACCESS_WRITE" f = open(TESTFN, "r+b") @@ -214,7 +222,10 @@ def test_both(): "Write-through memory map memory not updated properly.") m.flush() del m, f - verify(open(TESTFN).read() == 'c'*mapsize, + f = open(TESTFN, 'rb') + stuff = f.read() + f.close() + verify(open(TESTFN, 'rb').read() == 'c'*mapsize, "Write-through memory map data file not updated properly.") print " Opening mmap with access=ACCESS_COPY" |