pytest学习(3)
在pytest 2.0以上的版本里,我们也可以通过python -m pytest ...来调用。这实际上和pytest 。。。几乎一摸一样。
只是用python的时候,把当面目录也加入到sys.path中。
pytest的返回值如下:
Exit code 0: All tests were collected and passed successfully
Exit code 1: Tests were collected and run but some of the tests failed
Exit code 2: Test execution was interrupted by the user
Exit code 3: Internal error happened while executing tests
Exit code 4: pytest command line usage error
Exit code 5: No tests were collected
pytest的一些常用的命令你:
pytest --version 显示pytest import的版本,以及已经注册的插件。
C:\fitme\httpie\tests>pytest --version
This is pytest version 3.1.3, imported from c:\python35\lib\site-packages\pytest.py
setuptools registered plugins:
pytest-httpbin-0.2.3 at c:\python35\lib\site-packages\pytest_httpbin\plugin.py
pytest 碰到第几个错误停止:
pytest -x # stop after first failure
pytest --maxfail=2 # stop after two failures
指定路径啊,文件啊,文件里的函数,类等进行测试。
pytest test_mod.py # run tests in module
pytest somepath # run all tests below somepath
pytest -k stringexpr # only run tests with names that match the
# "string expression", e.g. "MyClass and not method"
# will select TestMyClass.test_something
# but not TestMyClass.test_method_simple
pytest test_mod.py::test_func # only run tests that match the "node ID",
# e.g. "test_mod.py::test_func" will select
# only test_func in test_mod.py
pytest test_mod.py::TestClass::test_method # run a single method in
# a single class
pytest学习(3)的更多相关文章
- [转载]pytest学习笔记
pytest学习笔记(三) 接着上一篇的内容,这里主要讲下参数化,pytest很好的支持了测试函数中变量的参数化 一.pytest的参数化 1.通过命令行来实现参数化 文档中给了一个简单的例子, ...
- Pytest学习(三) - setup和teardown的使用
一.前言 从文章标题可以看出,就是初始化和释放的操作,根据我的java习惯来学习pytest,个人感觉没差太多,理解上也不是很难. 哦,对了,差点跑题了,这个框架是基于Python语言的,在学习的时候 ...
- pytest学习笔记
From: https://blog.csdn.net/gaowg11/article/details/54910974 由于对测试框架了解比较少,所以最近看了下pytest测试框架,对学习心得做个记 ...
- pytest 学习笔记一 入门篇
前言 之前做自动化测试的时候,用的测试框架为Python自带的unittest框架,随着工作的深入,发现了另外一个框架就是pytest (官方地址文档http://www.pytest.org/en/ ...
- pytest学习笔记(一)
这两天在学习pytest,之前有小用到pytest,觉得这个测试框架很灵巧,用在实现接口自动化(pytest+requests)非常的轻便,然后很有兴致的决定学习下,然后又发现了pytest-sele ...
- Pytest学习(一)- 入门及基础
前言 十一也赶上自己刚出院,本想在十一放假前用假期刷完Pytest的,结果被希洛克神话吸引,再次回归毒奶粉,一直奋斗到距离上班还有两天,引导石刷没了,就没了智慧. 当然也没出过神话,结果一怒之下卸载, ...
- Pytest学习(二) - 断言的使用
一.前言 学习pytest总会习惯性的和unittest对比使用,自然就断言pytest和unittest也是有些区别的. 二.断言对比 unittest 断言 assertEqual(a, b) # ...
- Pytest学习笔记3-fixture
前言 个人认为,fixture是pytest最精髓的地方,也是学习pytest必会的知识点. fixture用途 用于执行测试前后的初始化操作,比如打开浏览器.准备测试数据.清除之前的测试数据等等 用 ...
- pytest学习笔记(三)
接着上一篇的内容,这里主要讲下参数化,pytest很好的支持了测试函数中变量的参数化 一.pytest的参数化 1.通过命令行来实现参数化 文档中给了一个简单的例子, test_compute.py ...
- pytest学习笔记(二)
继续文档的第二章 (一)pytest中可以在命令行中静态/动态添加option,这里没什么好讲的,略过... 这里面主要讲下如何试用skip/xfail,还有incremental(包含一些列的测试步 ...
随机推荐
- LTE/EPC中,MME怎么找到UE的HSS的?
http://bbs.c114.net/forum.php?mod=viewthread&tid=486247 HSS---归属用户服务器,我的理解:一般来说只有一个,或者是一个分布式数据库. ...
- enter & keypress
enter & keypress https://stackoverflow.com/questions/905222/enter-key-press-event-in-javascript ...
- [CQOI2012]局部极小值
题目链接 注意到\(4\times 7\)的矩阵的局部极小值最多只有8个,可以状压. 设\(f[i][sta]\)表示从小到大填数,当前填到\(i\),极小值的填充状态为\(sta\)的方案数. 考虑 ...
- [洛谷P1801]黑匣子_NOI导刊2010提高(06)
题目大意:两个操作:向一个可重集中加入一个元素:询问第$k$大的数($k$为之前询问的个数加一) 题解:离散化,权值线段树直接查询 卡点:无 C++ Code: #include <cstdio ...
- BZOJ3289 Mato的文件管理 【莫队 + 树状数组】
3289: Mato的文件管理 Time Limit: 40 Sec Memory Limit: 128 MB Submit: 3964 Solved: 1613 [Submit][Status] ...
- Codeforces Round #531 (Div. 3) ABCDEF题解
Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...
- xiaoluo同志Linux学习之CentOS6.4
小罗同志写的不错,弄个列表过来啊 Linux学习之CentOS(三十六)--FTP服务原理及vsfptd的安装.配置 xiaoluo501395377 2013-06-09 01:04 阅读:56 ...
- Topcoder SRM 608 div1 题解
Easy(300pts): 题目大意:有n个盒子,一共有S个苹果,每个盒子有多少个苹果不知道,但是知道每个盒子的苹果下限和上限.现在要至少选择X个苹果,问如果要保证无论如何都能获得至少X个苹果,至少需 ...
- [洛谷P1074] 靶形数独
洛谷题目链接:靶形数独 题目描述 小城和小华都是热爱数学的好学生,最近,他们不约而同地迷上了数独游戏,好胜的他们想用数独来一比高低.但普通的数独对他们来说都过于简单了,于是他们向 Z 博士请教,Z 博 ...
- 【bzoj1096-仓库建设】斜率优化
dsy1096: [ZJOI2007]仓库建设 [问题描述] L公司有N个工厂,由高到底分布在一座山上.如图所示,工厂1在山顶,工厂N在山脚. 由于这座山处于高原内陆地区(干燥少雨),L公司一般把产品 ...