python 断言大全
1. 小数位模糊等于
自动化脚本最重要的是断言,正确设置断言以后才能帮助我们判断测试用例执行结果。
在小同事的帮助下,整理了一份比较详细的断言方法。
一、先说说unittest常用的断言吧
常用的就以下几个,网上一搜一大堆。python版本2.7以上都可以调用了。
| 断言语法 | 解释 |
| (默认为7),如果在place位以内不同则断言失败。 | |
|
assertDictContainsSubset(expected, actual[, msg]) |
个多行字符串是相等的 |
|
assertNotAlmostEqual(first, second[, ...]) |
Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is less than the given delta. |
|
assertNotAlmostEquals(first, second[, ...]) |
Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the between the two objects is less than the given delta. |
|
assertNotEqual(first, second[, msg]) |
Fail if the two objects are equal as determined by the ‘==’ |
|
assertNotEquals(first, second[, msg]) |
Fail if the two objects are equal as determined by the ‘==’ |
|
assertNotIn(member, container[, msg]) |
Just like self.assertTrue(a not in b), but with a nicer default message. |
|
assertNotIsInstance(obj, cls[, msg]) |
Included for symmetry with assertIsInstance. |
|
assertNotRegexpMatches(text, unexpected_regexp) |
如果文本匹配正则表达式,将失败。 |
|
assertRaises(excClass[, callableObj]) |
除非excclass类抛出异常失败 |
|
assertRaisesRegexp(expected_exception, ...) |
认为在引发异常的情况下消息匹配一个正则表达式。 |
|
assertRegexpMatches(text, expected_regexp[, msg]) |
测试失败,除非文本匹配正则表达式。 |
|
assertSequenceEqual(seq1, seq2[, msg, seq_type]) |
有序序列的相等断言 (like lists and tuples). |
|
assertSetEqual(set1, set2[, msg]) |
A set-specific equality assertion. |
|
assertTrue(expr[, msg]) |
Check that the expression is true. |
|
assertTupleEqual(tuple1, tuple2[, msg]) |
A tuple-specific equality assertion. |
|
assert_(expr[, msg]) |
Check that the expression is true. |
三、在unittest包里面看到的比较全的断言
python 断言大全的更多相关文章
- Python 资源大全中文版
Python 资源大全中文版 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-python 是 vinta 发起维护的 Python 资源列 ...
- [转载]Python 资源大全
原文链接:Python 资源大全 环境管理 管理 Python 版本和环境的工具 p – 非常简单的交互式 python 版本管理工具. pyenv – 简单的 Python 版本管理工具. Vex ...
- Python 库大全
作者:Lingfeng Ai链接:http://www.zhihu.com/question/24590883/answer/92420471来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非 ...
- [转]Python 资源大全中文版
摘自:https://github.com/jobbole/awesome-python-cn 我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesom ...
- python模块大全
python模块大全2018年01月25日 13:38:55 mcj1314bb 阅读数:3049 pymatgen multidict yarl regex gvar tifffile jupyte ...
- 【python】Python 资源大全中文版
申明:感谢原作者的整理与分享,本篇文章分享自:https://www.jianshu.com/p/9c6ae64a1bd7 GitHub 上有一个 Awesome - XXX 系列的资源整理,资源非常 ...
- Python 资源大全
我想很多程序员应该记得 GitHub 上有一个 Awesome - XXX 系列的资源整理.awesome-python 是 vinta 发起维护的 Python 资源列表,内容包括:Web框架.网络 ...
- 年薪20万Python工程师进阶(7):Python资源大全,让你相见恨晚的Python库
我是 环境管理 管理 Python 版本和环境的工具 pyenv – 简单的 Python 版本管理工具. Vex – 可以在虚拟环境中执行命令. virtualenv – 创建独立 Python 环 ...
- Python资料大全
说明:以下文章为转载,有英文原文和中文整理翻译,对原作者和译者的工作表示极大感谢!!! 英文原文:https://github.com/vinta/awesome-python 中文译文:https: ...
随机推荐
- get与post需要注意的几点 (转)
get与post需要注意的几点 在面试或者笔试时,经常会被问到 HTTP 方法中 get 和 post 的异同点.本文简单整理归纳了一下,以备忘. 1."get/post" VS ...
- Job for php-fpm.service failed because the control process exited with error code. See "systemctl status php-fpm.service" and "journalctl -xe" for details.
[root@web01 ~]# systemctl start php-fpm Job for php-fpm.service failed because the control process ...
- delete指针
是释放指针所指向的内存,而不是删除指针本身
- CentOS7下Docker中构建Jenkins容器
背景 在CentOS搭建Docker完成后,我们需要在Docker中搭建Jenkins用来实现工程自动部署. 安装前提 jdk已安装,安装目录如:usr/java/jdk1.8.0_161 maven ...
- if语句题目练习
#print("您好") # # count=1 #count 表示计数 # while count<=8: # print("你是小学僧吗?") # p ...
- Python3基础 list len 输出元素的个数
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- CodeForces 459C Pashmak and Buses(构造)题解
题意:n个人,k辆车,要求d天内任意两人都不能一直在同一辆车,能做到给出构造,不能输出-1 思路:我们把某一个人这d天的车号看成一个d位的数字,比如 1 1 2 3代表第一天1号车.第二天1号车.第三 ...
- 【无法使用yum安装软件】使用yum命令安装软件提示No package numactl.x86_64 available.
在安装mysql时需要安装numactl.x86_64 使用yum -y install numactl.x86_64时报错 [root@sdp6 mysql]# yum -y install num ...
- oracle的loop等循环语句的几个用法小例子
--loop循环用法 (输出1到10) declare v_num number(2) := 0; begin loop v_num := v_num + 1; exit when v_num > ...
- (转)Introductory guide to Generative Adversarial Networks (GANs) and their promise!
Introductory guide to Generative Adversarial Networks (GANs) and their promise! Introduction Neural ...