-from test_support import verify, TESTFN, unlink
+from test_support import verify, TESTFN
import mmap
-import os, re, sys
+import os, re
PAGESIZE = mmap.PAGESIZE
"Test mmap module on Unix systems and Windows"
# Create a file to be mmap'ed.
+ if os.path.exists(TESTFN):
+ os.unlink(TESTFN)
f = open(TESTFN, 'w+')
try: # unlink TESTFN no matter what
# Modify the file's content
print "\n Modifying file's content..."
m[0] = '3'
- m[PAGESIZE +3: PAGESIZE +3+3]='bar'
+ m[PAGESIZE +3: PAGESIZE +3+3] = 'bar'
# Check that the modification worked
print ' Contents of byte 0:', repr(m[0])
m.flush()
# Test doing a regular expression match in an mmap'ed file
- match=re.search('[A-Za-z]+', m)
+ match = re.search('[A-Za-z]+', m)
if match is None:
print ' ERROR: regex match on mmap failed!'
else:
except OSError:
pass
try:
- unlink(TESTFN)
+ os.unlink(TESTFN)
except OSError:
pass