python测试驱动开发实例
更新时间:2014年10月08日 12:00:05 投稿:shichen2014
这篇文章主要介绍了python测试驱动开发实例,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了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程序设计有所帮助。
相关文章
Python中bytes字节串和string字符串之间的转换方法
python中字节字符串不能格式化,获取到的网页有时候是字节字符串,需要转化后再解析,下面这篇文章主要给大家介绍了关于Python中bytes字节串和string字符串之间的转换方法,需要的朋友可以参考下2022-01-01
Python利用ORM控制MongoDB(MongoEngine)的步骤全纪录
MongoEngine是一个对象文档映射器(ODM),相当于一个基于SQL的对象关系映射器(ORM),下面这篇文章主要给大家介绍了关于Python利用ORM控制MongoDB(MongoEngine)的相关资料,需要的朋友可以参考下2018-09-09
python使用matplotlib绘图时图例显示问题的解决
matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。下面这篇文章主要给大家介绍了在python使用matplotlib绘图时图例显示问题的解决方法,需要的朋友可以参考学习,下面来一起看看吧。2017-04-04


最新评论