手机
当前位置:查字典教程网 >脚本专栏 >python >python测试驱动开发实例
python测试驱动开发实例
摘要:本文实例讲述了python测试驱动开发的方法,分享给大家供大家参考。具体方法如下:importunittestfrommainimportS...

本文实例讲述了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测试驱动开发实例】相关文章:

python 自动提交和抓取网页

python k-近邻算法实例分享

python单链表实现代码实例

python使用新浪微博api上传图片到微博示例

Python 时间处理datetime实例

python判断、获取一张图片主色调的2个实例

python装饰器使用方法实例

python海龟绘图实例教程

python从ftp下载数据保存实例

python抓取网页图片示例(python爬虫)

精品推荐
分类导航