]> granicus.if.org Git - python/commitdiff
Don't try to close a non-open file.
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 25 Mar 2008 06:35:10 +0000 (06:35 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 25 Mar 2008 06:35:10 +0000 (06:35 +0000)
Don't let file removal cause the test to fail.

Lib/test/test_set.py

index 3d09d87fdb0e5d151cb0f59cc5cd74caac61dc75..6b3df3dd653259db3d5b64b5d4759bf33f6fdd5b 100644 (file)
@@ -283,15 +283,15 @@ class TestJointOps(unittest.TestCase):
         w = ReprWrapper()
         s = self.thetype([w])
         w.value = s
+        fo = open(test_support.TESTFN, "wb")
         try:
-            fo = open(test_support.TESTFN, "wb")
             print >> fo, s,
             fo.close()
             fo = open(test_support.TESTFN, "rb")
             self.assertEqual(fo.read(), repr(s))
         finally:
             fo.close()
-            os.remove(test_support.TESTFN)
+            test_support.unlink(test_support.TESTFN)
 
     def test_do_not_rehash_dict_keys(self):
         n = 10
@@ -626,15 +626,15 @@ class TestBasicOps(unittest.TestCase):
             self.assertEqual(repr(self.set), self.repr)
 
     def test_print(self):
+        fo = open(test_support.TESTFN, "wb")
         try:
-            fo = open(test_support.TESTFN, "wb")
             print >> fo, self.set,
             fo.close()
             fo = open(test_support.TESTFN, "rb")
             self.assertEqual(fo.read(), repr(self.set))
         finally:
             fo.close()
-            os.remove(test_support.TESTFN)
+            test_support.unlink(test_support.TESTFN)
 
     def test_length(self):
         self.assertEqual(len(self.set), self.length)