[pypy-svn] pypy default: Fix mmap test on Windows: offset must be a multiple of allocation granularity

amauryfa commits-noreply at bitbucket.org
Fri Feb 18 14:03:36 CET 2011


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r42163:d97f79177ee8
Date: 2011-02-18 13:42 +0100
http://bitbucket.org/pypy/pypy/changeset/d97f79177ee8/

Log:	Fix mmap test on Windows: offset must be a multiple of allocation
	granularity

diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -519,13 +519,15 @@
         assert b[:] == "foobar"
 
     def test_offset(self):
-        from mmap import mmap
+        from mmap import mmap, ALLOCATIONGRANULARITY
         f = open(self.tmpname + "y", "w+")
-        f.write("foobar" * 3000)
+        f.write("foobar" * ALLOCATIONGRANULARITY)
         f.flush()
-        m = mmap(f.fileno(), 4, offset=8192)
-        assert m[:] == "obar"
-        assert len(m) == 4
+        size = ALLOCATIONGRANULARITY
+        offset = 2 * ALLOCATIONGRANULARITY
+        m = mmap(f.fileno(), size, offset=offset)
+        assert m[:] == ("foobar" * ALLOCATIONGRANULARITY)[offset:offset+size]
+        assert len(m) == size
         m.close()
         f.close()
 


More information about the Pypy-commit mailing list