下面是unittest模块的常用方法:

assertEqual(a, b)     a == b

assertNotEqual(a, b)     a != b

assertTrue(x)     bool(x) is True

assertFalse(x)     bool(x) is False

assertIs(a, b)     a is b     2.7

assertIsNot(a, b)     a is not b     2.7

assertIsNone(x)     x is None     2.7

assertIsNotNone(x)     x is not None     2.7

assertIn(a, b)     a in b     2.7

assertNotIn(a, b)     a not in b     2.7

assertIsInstance(a, b)     isinstance(a, b)     2.7

assertNotIsInstance(a, b)     not isinstance(a, b)     2.7

assertAlmostEqual(a, b)     round(a-b, 7) == 0

assertNotAlmostEqual(a, b)     round(a-b, 7) != 0

assertGreater(a, b)     a > b     2.7

assertGreaterEqual(a, b)     a >= b     2.7

assertLess(a, b)     a < b     2.7

assertLessEqual(a, b)     a <= b     2.7

assertRegexpMatches(s, re)     regex.search(s)     2.7

assertNotRegexpMatches(s, re)     not regex.search(s)     2.7

assertItemsEqual(a, b)     sorted(a) == sorted(b) and works with unhashable objs     2.7

assertDictContainsSubset(a, b)     all the key/value pairs in a exist in b     2.7

assertMultiLineEqual(a, b)     strings     2.7

assertSequenceEqual(a, b)     sequences     2.7

assertListEqual(a, b)     lists     2.7

assertTupleEqual(a, b)     tuples     2.7

assertSetEqual(a, b)     sets or frozensets     2.7

assertDictEqual(a, b)     dicts     2.7

assertMultiLineEqual(a, b)     strings     2.7

assertSequenceEqual(a, b)     sequences     2.7

assertListEqual(a, b)     lists     2.7

assertTupleEqual(a, b)     tuples     2.7

assertSetEqual(a, b)     sets or frozensets     2.7

assertDictEqual(a, b)     dicts     2.7

【python】unittest中常用的assert语句的更多相关文章

  1. SQL Server中常用的SQL语句(转):

    SQL Server中常用的SQL语句 转自:http://www.cnblogs.com/rainman/archive/2013/05/04/3060428.html 1.概述 名词 笛卡尔积.主 ...

  2. 【转载】Python编程中常用的12种基础知识总结

    Python编程中常用的12种基础知识总结:正则表达式替换,遍历目录方法,列表按列排序.去重,字典排序,字典.列表.字符串互转,时间对象操作,命令行参数解析(getopt),print 格式化输出,进 ...

  3. Python编程中常用的12种基础知识总结

    原地址:http://blog.jobbole.com/48541/ Python编程中常用的12种基础知识总结:正则表达式替换,遍历目录方法,列表按列排序.去重,字典排序,字典.列表.字符串互转,时 ...

  4. 面试、笔试中常用的SQL语句(数据库知识必杀)一共50个!!!

    Student(S#,Sname,Sage,Ssex) 学生表  Course(C#,Cname,T#) 课程表  SC(S#,C#,score) 成绩表  Teacher(T#,Tname) 教师表 ...

  5. Python 数据分析中常用的可视化工具

    Python 数据分析中常用的可视化工具 1 Matplotlib 用于创建出版质量图表的绘图工具库,目的是为 Python 构建一个 Matlab 式的绘图接口. 1.1 安装 Anaconada ...

  6. 第8.34节 《Python类中常用的特殊变量和方法》总结

    本章介绍了Python类中常用的特殊变量和方法,这些特殊变量和方法都有特殊的用途,是Python强大功能的基石之一,许多功能非常有Python特色.由于Python中一切皆对象,理解这些特殊变量和方法 ...

  7. 第8章 Python类中常用的特殊变量和方法目录

    第8章 Python类中常用的特殊变量和方法 第8.1节 Python类的构造方法__init__深入剖析:语法释义 第8.2节 Python类的__init__方法深入剖析:构造方法案例详解 第8. ...

  8. python数据分析中常用的库

    Python是数据处理常用工具,可以处理数量级从几K至几T不等的数据,具有较高的开发效率和可维护性,还具有较强的通用性和跨平台性,这里就为大家分享几个不错的数据分析工具,需要的朋友可以参考下 Pyth ...

  9. 工作中常用的sql语句以及知识整理

    一.常用的sql语句 1.建表语句 create table tabname(colname1 type1 [not null][primary key], colname2 type2,...) 根 ...

随机推荐

  1. csdn第八名

    编号:1028时间:2016年7月18日11:49:17功能:csdn第八名URL :http://blog.csdn.net/21aspnet

  2. OpenvSwitch架构

    Openvswitch的架构 数据库结构和OVS-VSCTL # ps aux | grep openvswitch root      1117  0.0  0.0  21200  1580 ?   ...

  3. log4j 应用

    前言: 该片文章旨在对于刚入门的log4j学习的同学们,看完这篇,应该可以提高了. 主要内容还是根据log4j的配置文件中的各个配置来进行解析 正文: log4j 使用参数 log4j配置文件示例: ...

  4. node实现http上传文件进度条 -我们到底能走多远系列(37)

    我们到底能走多远系列(37) 扯淡: 又到了一年一度的跳槽季,相信你一定准备好了,每每跳槽,总有好多的路让你选,我们的未来也正是这一个个选择机会组合起来的结果,所以尽可能的找出自己想要的是什么再做决定 ...

  5. yii点击上传图片后立即显示

    结合yii上传做的图片上传后立即显示,自己琢磨的,有点low <script type="text/javascript">//下面用于图片上传预览功能function ...

  6. C#裁剪照片并保存

    /// <summary>    ///     /// </summary>    /// <summary>    /// 生成缩略图    /// </ ...

  7. HDU 3555 数位dp

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)Total Submi ...

  8. ZOJ 1243 URLs

    /*In the early nineties, the World Wide Web (WWW) was invented. Nowadays, most people think that the ...

  9. spark yarn-cluster 和 yarn-client提交的配置

    1. spark conf 目录下需要配置进去hadoop home 2.需要spark 提交的配置文件 加上‘-- master yarn-cluster/yarn-client’设置提交的模式

  10. URAL 1160 Network(最小生成树)

    Network Time limit: 1.0 secondMemory limit: 64 MB Andrew is working as system administrator and is p ...