Commit fd69208b authored by Tim Peters's avatar Tim Peters

Change test_mmap.py to use test_support.TESTFN instead of hardcoded "foo",

and wrap the body in try/finally to ensure TESTFN gets cleaned up no
matter what.
parent 8c3e91ef
from test_support import verify
from test_support import verify, TESTFN, unlink
import mmap
import os, re, sys
......@@ -7,9 +7,10 @@ PAGESIZE = mmap.PAGESIZE
def test_both():
"Test mmap module on Unix systems and Windows"
# Create an mmap'ed file
f = open('foo', 'w+')
# Create a file to be mmap'ed.
f = open(TESTFN, 'w+')
try: # unlink TESTFN no matter what
# Write 2 pages worth of data to the file
f.write('\0'* PAGESIZE)
f.write('foo')
......@@ -118,7 +119,17 @@ def test_both():
verify(0, 'Could seek beyond the new size')
m.close()
os.unlink("foo")
finally:
try:
f.close()
except OSError:
pass
try:
unlink(TESTFN)
except OSError:
pass
print ' Test passed'
test_both()
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