mirror of https://github.com/python/cpython
Remove the test file before writing it in case there is no write permission.
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).
This commit is contained in:
parent
60a819d681
commit
36a59b4a08
|
@ -163,6 +163,7 @@ class BaseTest(unittest.TestCase):
|
||||||
a = array.array(self.typecode, 2*self.example)
|
a = array.array(self.typecode, 2*self.example)
|
||||||
self.assertRaises(TypeError, a.tofile)
|
self.assertRaises(TypeError, a.tofile)
|
||||||
self.assertRaises(TypeError, a.tofile, cStringIO.StringIO())
|
self.assertRaises(TypeError, a.tofile, cStringIO.StringIO())
|
||||||
|
test_support.unlink(test_support.TESTFN)
|
||||||
f = open(test_support.TESTFN, 'wb')
|
f = open(test_support.TESTFN, 'wb')
|
||||||
try:
|
try:
|
||||||
a.tofile(f)
|
a.tofile(f)
|
||||||
|
|
|
@ -63,6 +63,7 @@ class TestBasic(unittest.TestCase):
|
||||||
self.assertEqual(list(d), range(7, 10))
|
self.assertEqual(list(d), range(7, 10))
|
||||||
d = deque(xrange(200), maxlen=10)
|
d = deque(xrange(200), maxlen=10)
|
||||||
d.append(d)
|
d.append(d)
|
||||||
|
test_support.unlink(test_support.TESTFN)
|
||||||
fo = open(test_support.TESTFN, "wb")
|
fo = open(test_support.TESTFN, "wb")
|
||||||
try:
|
try:
|
||||||
print >> fo, d,
|
print >> fo, d,
|
||||||
|
@ -281,6 +282,7 @@ class TestBasic(unittest.TestCase):
|
||||||
def test_print(self):
|
def test_print(self):
|
||||||
d = deque(xrange(200))
|
d = deque(xrange(200))
|
||||||
d.append(d)
|
d.append(d)
|
||||||
|
test_support.unlink(test_support.TESTFN)
|
||||||
fo = open(test_support.TESTFN, "wb")
|
fo = open(test_support.TESTFN, "wb")
|
||||||
try:
|
try:
|
||||||
print >> fo, d,
|
print >> fo, d,
|
||||||
|
|
|
@ -25,13 +25,10 @@ class TestGzip(unittest.TestCase):
|
||||||
filename = test_support.TESTFN
|
filename = test_support.TESTFN
|
||||||
|
|
||||||
def setUp (self):
|
def setUp (self):
|
||||||
pass
|
test_support.unlink(self.filename)
|
||||||
|
|
||||||
def tearDown (self):
|
def tearDown (self):
|
||||||
try:
|
test_support.unlink(self.filename)
|
||||||
os.unlink(self.filename)
|
|
||||||
except os.error:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def test_write (self):
|
def test_write (self):
|
||||||
|
|
|
@ -114,6 +114,7 @@ class UUFileTest(unittest.TestCase):
|
||||||
def test_encode(self):
|
def test_encode(self):
|
||||||
fin = fout = None
|
fin = fout = None
|
||||||
try:
|
try:
|
||||||
|
test_support.unlink(self.tmpin)
|
||||||
fin = open(self.tmpin, 'wb')
|
fin = open(self.tmpin, 'wb')
|
||||||
fin.write(plaintext)
|
fin.write(plaintext)
|
||||||
fin.close()
|
fin.close()
|
||||||
|
@ -143,6 +144,7 @@ class UUFileTest(unittest.TestCase):
|
||||||
def test_decode(self):
|
def test_decode(self):
|
||||||
f = None
|
f = None
|
||||||
try:
|
try:
|
||||||
|
test_support.unlink(self.tmpin)
|
||||||
f = open(self.tmpin, 'w')
|
f = open(self.tmpin, 'w')
|
||||||
f.write(encodedtextwrapped % (0644, self.tmpout))
|
f.write(encodedtextwrapped % (0644, self.tmpout))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
Loading…
Reference in New Issue