[Python-checkins] python/dist/src/Lib/test test_mmap.py,1.30,1.31
loewis at users.sourceforge.net
loewis at users.sourceforge.net
Thu Mar 3 12:23:13 CET 2005
Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12697/Lib/test
Modified Files:
test_mmap.py
Log Message:
Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
Index: test_mmap.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_mmap.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- test_mmap.py 13 Jan 2003 21:38:45 -0000 1.30
+++ test_mmap.py 3 Mar 2005 11:22:41 -0000 1.31
@@ -311,7 +311,43 @@
finally:
os.unlink(TESTFN)
+ # test mapping of entire file by passing 0 for map length
+ if hasattr(os, "stat"):
+ print " Ensuring that passing 0 as map length sets map size to current file size."
+ f = open(TESTFN, "w+")
+
+ try:
+ f.write(2**16 * 'm') # Arbitrary character
+ f.close()
+
+ f = open(TESTFN, "rb+")
+ mf = mmap.mmap(f.fileno(), 0)
+ verify(len(mf) == 2**16, "Map size should equal file size.")
+ vereq(mf.read(2**16), 2**16 * "m")
+ mf.close()
+ f.close()
+ finally:
+ os.unlink(TESTFN)
+
+ # test mapping of entire file by passing 0 for map length
+ if hasattr(os, "stat"):
+ print " Ensuring that passing 0 as map length sets map size to current file size."
+ f = open(TESTFN, "w+")
+ try:
+ f.write(2**16 * 'm') # Arbitrary character
+ f.close()
+
+ f = open(TESTFN, "rb+")
+ mf = mmap.mmap(f.fileno(), 0)
+ verify(len(mf) == 2**16, "Map size should equal file size.")
+ vereq(mf.read(2**16), 2**16 * "m")
+ mf.close()
+ f.close()
+
+ finally:
+ os.unlink(TESTFN)
+
print ' Test passed'
test_both()
More information about the Python-checkins
mailing list