Replace tearDown with NestedTempfile Fixture
Teardown isn't called if Setup errors, this should be more reliable. Change-Id: I7804738527b1da18908652cf5dee591d75fa66b5
This commit is contained in:
parent
4cfeb28d12
commit
61b6dfb604
|
@ -295,6 +295,9 @@ class TestFileHash(testtools.TestCase):
|
|||
def setUp(self):
|
||||
super(TestFileHash, self).setUp()
|
||||
|
||||
# Deletes tempfiles during teardown
|
||||
self.useFixture(fixtures.NestedTempfile())
|
||||
|
||||
self.file_1 = tempfile.mkstemp()[1]
|
||||
with open(self.file_1, "w") as fp:
|
||||
fp.write("test string")
|
||||
|
@ -303,11 +306,6 @@ class TestFileHash(testtools.TestCase):
|
|||
with open(self.file_2, "w") as fp:
|
||||
fp.write("test string2")
|
||||
|
||||
def tearDown(self):
|
||||
super(TestFileHash, self).tearDown()
|
||||
os.unlink(self.file_1)
|
||||
os.unlink(self.file_2)
|
||||
|
||||
def test_getfilehash_nofile(self):
|
||||
h = collect.getfilehash([])
|
||||
self.assertEquals(h, "d41d8cd98f00b204e9800998ecf8427e")
|
||||
|
|
Loading…
Reference in New Issue