python测试驱动开发实例
程序员文章站
2024-02-10 20:45:04
本文实例讲述了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程序设计有所帮助。
上一篇: Sai怎么画一个简笔画小白兔?
下一篇: 百度网盘网页版怎么下载超过2G的视频?