【发布时间】:2014-09-02 03:38:25
【问题描述】:
我创建了一个测试,在 setUp 中创建文件,如下所示:
class TestSomething :
def setUp(self):
# create file
fo = open('some_file_to_test','w')
fo.write('write_something')
fo.close()
def test_something(self):
# call some function to manipulate file
...
# do some assert
...
def test_another_test(self):
# another testing with the same setUp file
...
在测试结束时,无论成功与否,我都希望测试文件消失,所以 测试完成后如何删除文件?
【问题讨论】:
标签: python unit-testing testing