[Python-checkins] python/dist/src/Lib/test test_mmap.py,1.25,1.26
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Tue, 10 Sep 2002 13:49:17 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv31680/python/Lib/test
Modified Files:
test_mmap.py
Log Message:
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.
Index: test_mmap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** test_mmap.py 7 Sep 2002 05:56:21 -0000 1.25
--- test_mmap.py 10 Sep 2002 20:49:15 -0000 1.26
***************
*** 103,107 ****
print ' Attempting resize()'
try:
! m.resize( 512 )
except SystemError:
# resize() not supported
--- 103,107 ----
print ' Attempting resize()'
try:
! m.resize(512)
except SystemError:
# resize() not supported
***************
*** 197,200 ****
--- 197,203 ----
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.")
***************
*** 203,208 ****
if not sys.platform.startswith('win'):
verify(0, "Opening mmap with size+1 should raise ValueError.")
! del m
! del f
print " Opening mmap with access=ACCESS_WRITE"
--- 206,216 ----
if not sys.platform.startswith('win'):
verify(0, "Opening mmap with size+1 should raise ValueError.")
! 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"
***************
*** 215,219 ****
m.flush()
del m, f
! verify(open(TESTFN).read() == 'c'*mapsize,
"Write-through memory map data file not updated properly.")
--- 223,230 ----
m.flush()
del m, f
! 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.")