import os
from unittest import TestCase
class MyTest(TestCase):
def setUp(self):
if not os.path.exists('configfile'):
return self.skipTest('config file not found')
def test01(self):
# Do something with the file
with open('configfile') as fd:
self.assertEqual(fd.readlines().__len__(), 0)
您可以在特定的测试用例中使用setUp方法中的skipTest,例如:
如果配置文件不存在,test01将不会运行。你知道吗
相关问题 更多 >
编程相关推荐