python测试驱动开发实例
程序员文章站
2023-11-12 11:02:52
本文实例讲述了python测试驱动开发的方法,分享给大家供大家参考。具体方法如下:
import unittest
from main import samp...
本文实例讲述了python测试驱动开发的方法,分享给大家供大家参考。具体方法如下:
import unittest from main import sample class sampletest(unittest.testcase): def setup(self): print "create a new sample" self._sample = sample("b64e5843ca7db8199c405be565fa7f57") def teardown(self): print "destory the sample" self._sample = none def test_getvirusnamefromvt(self): "this md5 has the vt info" asample = sample("b64e5843ca7db8199c405be565fa7f57") dict_virusname = asample._getvirusnamefromvt() self.asserttrue(dict_virusname!=none) def test_getvirusnamefromvt2(self): "this md5 has not the vt info" asample = sample("2b666ffe98e465523e514d2b93b7666a") dict_virusname = asample._getvirusnamefromvt () self.asserttrue(len(dict_virusname) == 0) if __name__=="__main__": #unittest.main() suite = unittest.testloader().loadtestsfromtestcase(sampletest) unittest.texttestrunner(verbosity=2).run(suite)
希望本文所述对大家的python程序设计有所帮助。
上一篇: 抖音权重怎么查询