[Python-checkins] python/dist/src/Lib/test test_mmap.py,1.19.8.4,1.19.8.5

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2002年9月24日 09:21:38 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv17109/Lib/test
Modified Files:
 Tag: release22-maint
	test_mmap.py 
Log Message:
Replaced this with the 2.3 test_mmap, which contains Windows-specific
fixes for the "try to resize it" test (Windows grows the underlying
file then, and that screws up later tests that assume the underlying
file has not changed size, as was true on the box (Linux) the person
who changed this test in 2.2 to begin with tried it on). Without this
change, test_mmap fails on Windows. Now it passes again.
Index: test_mmap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v
retrieving revision 1.19.8.4
retrieving revision 1.19.8.5
diff -C2 -d -r1.19.8.4 -r1.19.8.5
*** test_mmap.py	7 Sep 2002 05:58:28 -0000	1.19.8.4
--- test_mmap.py	24 Sep 2002 16:21:36 -0000	1.19.8.5
***************
*** 1,3 ****
! from test_support import verify, vereq, TESTFN
 import mmap
 import os, re
--- 1,3 ----
! from test.test_support import verify, vereq, TESTFN
 import mmap
 import os, re
***************
*** 19,23 ****
 f.write('0円'* (PAGESIZE-3) )
 f.flush()
- 
 m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
 f.close()
--- 19,22 ----
***************
*** 104,108 ****
 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
***************
*** 198,201 ****
--- 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.")
***************
*** 204,209 ****
 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,220 ****
 "Write-through memory map memory not updated properly.")
 m.flush()
! del m, f
! verify(open(TESTFN).read() == 'c'*mapsize,
 "Write-through memory map data file not updated properly.")
 
--- 222,231 ----
 "Write-through memory map memory not updated properly.")
 m.flush()
! m.close()
! f.close()
! f = open(TESTFN, 'rb')
! stuff = f.read()
! f.close()
! verify(stuff == 'c'*mapsize,
 "Write-through memory map data file not updated properly.")
 

AltStyle によって変換されたページ (->オリジナル) /