python测试驱动开发实例

yipeiwu_com5年前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在openstreetmap地图上绘制路线图的实现

python在openstreetmap地图上绘制路线图的实现

利用python进行经纬度轨迹展示 嘿!各位好久不见,距离第一次发博客已经过去两年多了,本人也从本科生变成了研究生,好了书归正传,最近在做一个关于航班滑行路径轨迹的项目,目的是将航班的经...

Pandas实现DataFrame按行求百分数(比例数)

简述 Motivation 一般来说,每个部分的内容数量是较为容易获取的,但比例(百分数)这样的数据是二次数据,这样的操作很常见 比例的信息相比于纯粹的数字更体现的整体体系的内部变化迁移...

python检索特定内容的文本文件实例

windows环境下python2.7 脚本指定一个参数作为要检索的字符串 例如: >find.py ./ hello # coding=utf-8 import os im...

利用python将json数据转换为csv格式的方法

假设.json文件中存储的数据为: {"type": "Point", "link": "http://www.dianping.com/newhotel/22416995", "c...

Python实现字典去除重复的方法示例

本文实例讲述了Python实现字典去除重复的方法。分享给大家供大家参考,具体如下: #!/usr/bin/env python # encoding: utf-8 #字典去重小代码...