python用于测试的failIf,failUnless
2015-07-27 09:23
597 查看
#!/usr/bin/python #-*- coding:utf-8 -*- import unittest class ArithTestSuper(unittest.TestCase): def setUp(self): print "seting up arithtest cases" def tearDown(self): print "cleaning up arithtest cases" class ArithTest(ArithTestSuper): def runTest(self): ''' test addtion and succeed ''' print "running arithtest" self.failUnless(1+1==2,"fails") self.failIf(1+1!=2,"fails againg") self.failUnlessEqual(1+1,2,"more troble")
后面的断言语句,可以这样理解,如果fail后面的语句为真,则发生错误
例如 failIf ,如果( IF 条件)为真,则fail ,同理,如果 ( unless 条件 ) 为真,则fail ,unless的意思是:如果 不,这里等价于not,即(not 条件)如果条件为假,则fail,
相关文章推荐
- Python logging模块详解
- Python - 命令行参数
- 【python】hust virtual judge 交题记录抓取
- 获取分享社最新一期的迅雷分享账号
- 用Python模拟浏览器登录
- python 爬图 helloworld
- Python中特殊函数集锦
- 在Python中的Django框架中进行字符串翻译
- 在Python的Django框架中创建语言文件
- Python多线程结合队列下载百度音乐的方法
- Python实现删除当前目录下除当前脚本以外的文件和文件夹实例
- python数组过滤实现方法
- python内建函数a-b部分(一)
- python内置函数(二)
- 走进Python世界(五)数据类型 5. 序列类型-字典(Dictionary)
- python系列------open函数
- 使用python获取实时卫星云图
- C和Python实现冒泡法排序
- Python request第三方库的安装
- Thrift 連線至 Hbase 使用Python - ImportError: No module named Thrift