unittest学习5-断言
unittest提供了以下断言方式:
方法 |
检查 |
新进 |
---|---|---|
|
||
|
||
|
||
|
||
|
3.1 |
|
|
3.1 |
|
|
3.1 |
|
|
3.1 |
|
|
3.1 |
|
|
3.1 |
|
|
3.2 |
|
|
3.2 |
所有assert方法都接受一个msg参数,该参数可以作为错误消息输出。例如:
assertEqual
(first, second, msg=None)
比较first和second是否相等,不相等可以指定输出msg,测试失败
assertNotEqual
(first, second, msg=None)
比较first和second是否不相等,如果值相等,则输出失败
assertTrue
(expr, msg=None)
assertFalse(expr,msg=None)
测试expr为true或者false
assertIs
(first, second, msg=None)
assertIsNot
(first, second, msg=None)
判断first和second是否为同一对象
assertIsNone
(expr, msg=None)
assertIsNotNone
(expr, msg=None
判断expr是否为None
assertIn
(first, second, msg=None)
assertNotIn
(first, second, msg=None)
判断first是否在second中
assertIsInstance
(obj, cls, msg=None)
assertNotIsInstance
(obj, cls, msg=None)
判断obj是否为cls的实例
最新文章
- 为什么基于Windows Server 2008 R2的网络负载均衡(NLB)配置的时候总会报错“主机不可访问”?
- Qt、VTK配置常见问题
- C#中三种定时器对象的比较
- Linux编译内核提示'make menuconfig' requires the ncurses libraries错误
- OC语言--NSFileManager&;amp; NSFileHandle
- IDEA新建SpringMVC项目报错解决办法
- IOS APP IDs
- aps.net js获取服务器控件
- 超炫的Button按钮展开弧形动画效果
- DB Query Analyzer 6.03, the most excellent Universal DB Access tools on any Microsoft Windows OS
- 解决Linux(Loaded plugins: fastestmirror Please use /usr/bin/yum --help)
- tensorflow学习之(八)使用dropout解决overfitting(过拟合)问题
- linux上部署SpringBoot项目及遇到的问题
- 1411 - Ants(巨人与鬼)
- js 压缩上传的图片方法(默认上传的是file文件)
- CF949D Curfew
- if、else、elif
- 鸟哥的Linux私房菜——第八章
- delphi TOnFormVisibleChangeEvent 事件应用
- BackgroundWorker+ProgressBar+委托 实现多线程、进度条
热门文章
- [POI2010] GIL-Guilds - 二分图染色,DFS
- PP: Articial Intelligence—TheRevolution Hasn’t HappenedYet
- Linux shell unzip和tar 批量解压文件
- 2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛 Banana
- yii2 钩子函数
- element-ui的upload组件的clearFiles方法
- 数据预处理 | python 第三方库 imblearn 处理样本分布不均衡问题
- Struts2学习-struts.xml文件配置
- [Agc001A/At1979] BBQ Easy - 贪心
- ActiveMQ使用JDBC持久化