]> granicus.if.org Git - python/commitdiff
Ensure that this test will pass even if another test left an unwritable TESTFN.
authorNeal Norwitz <nnorwitz@gmail.com>
Sat, 6 Oct 2007 19:16:28 +0000 (19:16 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sat, 6 Oct 2007 19:16:28 +0000 (19:16 +0000)
Also use the safe unlink in test_support instead of rolling our own here.

Lib/test/test_bufio.py

index 14a926a570444899ea19e1fc54a7c1ea49aa7b98..4f5de10c631615d7223d3b166f5c851fb2519b6c 100644 (file)
@@ -13,6 +13,9 @@ class BufferSizeTest(unittest.TestCase):
         # Write s + "\n" + s to file, then open it and ensure that successive
         # .readline()s deliver what we wrote.
 
+        # Ensure we can open TESTFN for writing.
+        test_support.unlink(test_support.TESTFN)
+
         # Since C doesn't guarantee we can write/read arbitrary bytes in text
         # files, use binary mode.
         f = open(test_support.TESTFN, "wb")
@@ -31,11 +34,7 @@ class BufferSizeTest(unittest.TestCase):
             self.assert_(not line) # Must be at EOF
             f.close()
         finally:
-            try:
-                import os
-                os.unlink(test_support.TESTFN)
-            except:
-                pass
+            test_support.unlink(test_support.TESTFN)
 
     def drive_one(self, pattern):
         for length in lengths: