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中的bs4基础

安装 在命令提示符框中直接输入pip install beautifulsoup4 介绍 beautifulsoup是python的一个第三方库,和xpath一样,都是用来解析html数...

Python 运行.py文件和交互式运行代码的区别详解

Python 运行.py文件和交互式运行代码的区别详解

代码版本:3.6.3 1. 交互式运行代码会直接给出表达式的结果,运行代码文件必须print才能在控制台看到结果。 直接给出结果:   没有print是看不到结果的: 有p...

如何在python中使用selenium的示例

最近基于selenium写了一个python小工具,记录下学习记录,自己运行的环境是Ubuntu 14.04.4, Python 2.7,Chromium 49.0,ChromeDriv...

Python3模拟curl发送post请求操作示例

本文实例讲述了Python3模拟curl发送post请求操作。分享给大家供大家参考,具体如下: 后端给的接口样式: curl "http://65.33.44.43:509/pre/u...

python3个性签名设计实现代码

python3个性签名设计实现代码

本文实例为大家分享了python个性签名设计的具体代码,供大家参考,具体内容如下 参考博客:Python GUI Tkinter简单实现个性签名设计 参考博客:python3爬虫之设计签...