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程序设计有所帮助。

相关文章

在前一篇博客中我们介绍了加侧旋的乒乓球弧圈技术的模拟,本...
在近期conda的版本更新中,有可能会删除路径下的_sysconfigd...
本文主要展示了一些lambda表达式的使用示例,通过这些示例,...
本文通过对比Jax和Numpy计算Normalized Hamming Distance的过...
我们知道GPU加速在可并行化程度比较高的算法中,能够发挥出比...
Numpy这个库在Python编程中非常的常用,不仅在性能上补足了P...