]> granicus.if.org Git - python/commitdiff
Remove the test file before writing it in case there is no write permission.
authorNeal Norwitz <nnorwitz@gmail.com>
Thu, 10 Apr 2008 05:46:39 +0000 (05:46 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Thu, 10 Apr 2008 05:46:39 +0000 (05:46 +0000)
This might help fix some of the failures on Windows box(es).  It doesn't hurt
either way and ensure the tests are a little more self contained (ie have
less assumptions).

Lib/test/test_array.py
Lib/test/test_deque.py
Lib/test/test_gzip.py
Lib/test/test_uu.py

index a54594a450c01fefbdba4a05628207b9e447fd72..b11c9d601cc4e9784d65919327fc0011d9eccf1e 100755 (executable)
@@ -163,6 +163,7 @@ class BaseTest(unittest.TestCase):
         a = array.array(self.typecode, 2*self.example)
         self.assertRaises(TypeError, a.tofile)
         self.assertRaises(TypeError, a.tofile, cStringIO.StringIO())
+        test_support.unlink(test_support.TESTFN)
         f = open(test_support.TESTFN, 'wb')
         try:
             a.tofile(f)
index a185f78dba79b28aabd72ce78f5c137b25772d87..0b751d865cf59068c6ea7ff56504cbc89c593274 100644 (file)
@@ -63,6 +63,7 @@ class TestBasic(unittest.TestCase):
         self.assertEqual(list(d), range(7, 10))
         d = deque(xrange(200), maxlen=10)
         d.append(d)
+        test_support.unlink(test_support.TESTFN)
         fo = open(test_support.TESTFN, "wb")
         try:
             print >> fo, d,
@@ -281,6 +282,7 @@ class TestBasic(unittest.TestCase):
     def test_print(self):
         d = deque(xrange(200))
         d.append(d)
+        test_support.unlink(test_support.TESTFN)
         fo = open(test_support.TESTFN, "wb")
         try:
             print >> fo, d,
index 1704a60dc82e01fb83401e2bfbff3e6e2668e8da..a1a267e9914aec1ee06ef04c78e63a18b4105850 100644 (file)
@@ -25,13 +25,10 @@ class TestGzip(unittest.TestCase):
     filename = test_support.TESTFN
 
     def setUp (self):
-        pass
+        test_support.unlink(self.filename)
 
     def tearDown (self):
-        try:
-            os.unlink(self.filename)
-        except os.error:
-            pass
+        test_support.unlink(self.filename)
 
 
     def test_write (self):
index 346cfb2ced0526f0e09dede7508d1a2b3ed6309a..25d9b608b2523dfcdb655a7e99e46465c6eb144a 100644 (file)
@@ -114,6 +114,7 @@ class UUFileTest(unittest.TestCase):
     def test_encode(self):
         fin = fout = None
         try:
+            test_support.unlink(self.tmpin)
             fin = open(self.tmpin, 'wb')
             fin.write(plaintext)
             fin.close()
@@ -143,6 +144,7 @@ class UUFileTest(unittest.TestCase):
     def test_decode(self):
         f = None
         try:
+            test_support.unlink(self.tmpin)
             f = open(self.tmpin, 'w')
             f.write(encodedtextwrapped % (0644, self.tmpout))
             f.close()