summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index a6796d5..d225173 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -311,7 +311,43 @@ def test_both():
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()