Commit 05c7f27d authored by Kevin Modzelewski's avatar Kevin Modzelewski

mmap test fixes

parent 5576cae7
......@@ -119,7 +119,10 @@ class MmapTests(unittest.TestCase):
def test_access_parameter(self):
# Test for "access" keyword parameter
mapsize = 10
open(TESTFN, "wb").write("a"*mapsize)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("a"*mapsize)
with open(TESTFN, "wb") as f:
f.write("a"*mapsize)
f = open(TESTFN, "rb")
m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
self.assertEqual(m[:], 'a'*mapsize, "Readonly memory map data incorrect.")
......@@ -538,7 +541,10 @@ class MmapTests(unittest.TestCase):
@unittest.skipUnless(hasattr(mmap, 'PROT_READ'), "needs mmap.PROT_READ")
def test_prot_readonly(self):
mapsize = 10
open(TESTFN, "wb").write("a"*mapsize)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("a"*mapsize)
with open(TESTFN, "wb") as f:
f.write("a"*mapsize)
f = open(TESTFN, "rb")
m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
self.assertRaises(TypeError, m.write, "foo")
......@@ -550,7 +556,10 @@ class MmapTests(unittest.TestCase):
def test_io_methods(self):
data = "0123456789"
open(TESTFN, "wb").write("x"*len(data))
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("x"*len(data))
with open(TESTFN, "wb") as f:
f.write("x"*len(data))
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), len(data))
f.close()
......@@ -617,7 +626,10 @@ class MmapTests(unittest.TestCase):
m.close()
# Should not crash (Issue 5385)
open(TESTFN, "wb").write("x"*10)
# Pyston change: use a with statement to not rely on the destructor being called:
# open(TESTFN, "wb").write("x"*10)
with open(TESTFN, "wb") as f:
f.write("x"*10)
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), 0)
f.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment