From 6278799f8e34bf01de68f989f5f100913fb5e2f5 Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Fri, 11 May 2001 14:29:21 +0000 Subject: unlink() would normally be found in the "os" module, so use it from there. Remove unused import of "sys". If the file TESTFN exists before we start, try to remove it. Add spaces around the = in some assignments. --- Lib/test/test_mmap.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 427f4e6..eb31dc3 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -1,6 +1,6 @@ -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 @@ -8,6 +8,8 @@ def test_both(): "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 @@ -36,7 +38,7 @@ def test_both(): # 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]) @@ -49,7 +51,7 @@ def test_both(): 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: @@ -126,7 +128,7 @@ def test_both(): except OSError: pass try: - unlink(TESTFN) + os.unlink(TESTFN) except OSError: pass -- cgit v0.12