]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
unlink() would normally be found in the "os" module, so use it from there.
authorFred Drake <fdrake@acm.org>
Fri, 11 May 2001 14:29:21 +0000 (14:29 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 11 May 2001 14:29:21 +0000 (14:29 +0000)
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

index 427f4e6945187ba16c053572f1d17deefb258dde..eb31dc3a8d9aa4fb0d3753dab52a74066253d2c7 100644 (file)
@@ -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