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(包含一些列的测试步 ...
随机推荐
- winform 控件大小随着窗体自适应
3个方法: #region 控件缩放变量 double formWidth;//窗体原始宽度 double formHeight;//窗体原始高度 doubl ...
- web相关基础知识2
2017-12-14 17:14:22 块元素 典型代表,Div,h1-h6,p,ul,li 特点: ★独占一行 ★可以设置宽高 ★ 嵌套(包含)下,子块元素宽度(没有定义情况下)和父块元素宽度默认 ...
- c# 调用 matlab 引发初始化错误 异常
1. 除了matlab 编译的DLL 意外还需要引用 MWArray.dll 这个dill 在安装了 MCRInstaller.exe(matlab运行环境之后就会有了): 2. 最重要的一点.ne ...
- [Java] 文件上传下载项目(详细注释)
先上代码,最上方注释是文件名称(运行时要用到) FTServer.java /* FTServer.java */ import java.util.*; import java.io.*; publ ...
- 如何让旧浏览器支持HTML5新标签
HTML5出现也不短了,很多网站的页面都进行了改版,为了降低代码量(不需要起太多的类名),提升加载速度,提高标签的语义性,因此,在网页中大量使用了section,article,header等HTML ...
- redux-saga基本用法
redux-saga是管理redux异步操作的中间件,redux-saga通过创建sagas将所有异步操作逻辑收集在一个地方集中处理. sagas采用Generator函数来yield Effects ...
- Mysql History list length 值太大引起的问题
1. 环境 Mysql 主从 Mysql版本:5.1.49-log 系统:Red Hat Enterprise Linux Server release 5.4 64bit 2. 表面现象 数据库操 ...
- wget下载HTTPS链接
wget -c -O master.zip --no-check-certificate https://github.com/mitsuhiko/flask/archive/master.zip # ...
- SQLNET跟踪tnsping过程
原文地址:SQLNET跟踪tnsping过程 作者:yingyifeng306 sqlnet是oracle提供的与网络层面交互的一个工具,比如如何解析客户端发起的连接,如何对客户端发起的连接进行辨别, ...
- javascript实现倒计时(转)
<html> <head> <title>倒计时</title> <meta charset="utf-8"> < ...