Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e7789b1

Browse files
committed
Always try to delete the data file before and after the test.
This will hopefully avoid spurious failures if the file doesn't have the proper permissions to write for some reason.
1 parent 2595e76 commit e7789b1

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/test/test_gzip.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ class TestGzip(unittest.TestCase):
2525
filename = test_support.TESTFN
2626

2727
def setUp (self):
28-
pass
28+
test_support.unlink(self.filename)
2929

3030
def tearDown (self):
31-
try:
32-
os.unlink(self.filename)
33-
except os.error:
34-
pass
31+
test_support.unlink(self.filename)
3532

3633

3734
def test_write (self):

Lib/test/test_io.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ def writable(self):
7979

8080
class IOTest(unittest.TestCase):
8181

82+
def setUp(self):
83+
test_support.unlink(test_support.TESTFN)
84+
8285
def tearDown(self):
8386
test_support.unlink(test_support.TESTFN)
8487

@@ -619,6 +622,7 @@ class TextIOWrapperTest(unittest.TestCase):
619622
def setUp(self):
620623
self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n"
621624
self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ascii")
625+
test_support.unlink(test_support.TESTFN)
622626

623627
def tearDown(self):
624628
test_support.unlink(test_support.TESTFN)

0 commit comments

Comments
 (0)