pytest 一.安装和使用入门

# -*- coding: utf-8 -*-
# @Time : 2018/7/5 23:57
# @Author : onesilent
# @File : FirstTest.py
# @Project : PythonTestDemo
# content of test_sample.py
def func(x):
return x + 1
def test_answer():
assert func(3) == 5

# -*- coding: utf-8 -*-
# @Time : 2018/7/10 23:29
# @Author : onesilent
# @File : test_sysexit.py
# @Project : PythonTestDemo # content of test_sysexit.py
import pytest
def f():
raise SystemExit(1)
def test_mytest():
with pytest.raises(SystemExit):
f()

# -*- coding: utf-8 -*-
# @Time : 2018/7/11 0:00
# @Author : onesilent
# @File : test_class.py
# @Project : PythonTestDemo
# content of test_class.py
class TestClass(object):
def test_one(self):
x = "this"
assert 'h' in x
def test_two(self):
x = "hello"
assert hasattr(x, 'check')

# -*- coding: utf-8 -*-
# @Time : 2018/7/11 23:57
# @Author : onesilent
# @File : test_tmpdir.py
# @Project : PythonTestDemo # content of test_tmpdir.py
def test_needsfiles(tmpdir):
print (tmpdir)
assert 0

pytest --fixtures #此命令显示内置命令和custom fixtures 请注意,除非添加-v选项,否则此命令将省略带有前导_的 fixtures。

pytest 一.安装和使用入门的更多相关文章
- sass、less和stylus的安装使用和入门实践
刚 开始的时候,说实话,我很反感使用css预处理器这种新玩意的,因为其中涉及到了编程的东西,私以为很复杂,而且考虑到项目不是一天能够完成的,也很少是 一个人完成的,对于这种团队的项目开发,前端实践用c ...
- Linux上安装使用boost入门指导
Data Mining Linux上安装使用boost入门指导 获得boost boost分布 只需要头文件的库 使用boost建立一个简单的程序 准备使用boost二进制文件库 把你的程序链接到bo ...
- Oracle安装及使用入门
新手Oracle安装及使用入门 一.安装Oracle Step1 下载oracle压缩包并解压到同一文件夹下面 Step2 双击setup.exe进行安装 Step3:进入如下界面配置: 邮箱可不 ...
- Postman 安装及使用入门教程(我主要使用接口测试)
1.Postman 安装及使用入门教程(我主要使用接口测试)Postman的English官网:https://www.getpostman.com/chrome插件整理的Postman中文使用教程( ...
- Linux Supervisor的安装与使用入门
在linux或者unix操作系统中,守护进程(Daemon)是一种运行在后台的特殊进程,它独立于控制终端并且周期性的执行某种任务或等待处理某些发生的事件.由于在linux中,每个系统与用户进行交流的界 ...
- 20165223 Linux安装及命令入门
预备作业3:Linux安装及命令入门 一.VirtualBox和Ubuntu的安装 通过学习实践基于VirtualBox虚拟机安装Ubuntu图文教程,我开始学习虚拟机的安装,根据教程一步步试着安装. ...
- Git客户端的安装与配置入门
GitLab与Git客户端的安装与配置入门,每次配置完一段时间,就忘记配置过程了,为了自己和同学们以后有所参照,特记录了本次下载和配置,其实Git就是一个版本控制系统,类似于SVN,CVS等 下载:W ...
- 20155327预备作业3:Linux安装及命令入门
20155327预备作业3:Linux安装及命令入门 安装Linux操作系统 由于之前安装过所以这里就不再赘述了 掌握Linux命令的学习方法 学习路径: 常用Ubuntu快捷键: CTRL+ALT+ ...
- pytest+jenkins安装+allure导出报告
环境安装: windows7+64位 pytest:4.0.2 allure的安装:allure的python库pytest-allure-adaptor jenkins的安装:2.138.2 JDK ...
随机推荐
- 215.Spring Boot+Spring Security:初体验
[视频&交流平台] SpringBoot视频:http://t.cn/R3QepWG Spring Cloud视频:http://t.cn/R3QeRZc SpringBoot Shiro视频 ...
- jQuery入门基础(事件、DOM操作)
http://www.w3school.com.cn/b.asp 一.事件 1.常规事件——把js事件前面的on去掉 比如:js:onclick——JQuery:click 下面是 jQuery 中事 ...
- Swoft 缓存及Redis使用
配置 修改 /config/properties/cache.php 文件 return [ 'redis' => [ 'name' => 'redis', 'uri' => [ ' ...
- Lintcode - 20.骰子求和
题目: 扔 n 个骰子,向上面的数字之和为 S.给定 Given n,请列出所有可能的 S值及其相应的概率. 给定 n = 1,返回 [ [1, 0.17], [2, 0.17], [3, 0.17] ...
- web跨域问题(No 'Access-Control-Allow-Origin'..)
1. 问题 angular开发中连接java服务时出现跨域问题(No 'Access-Control-Allow-Origin'..). 如下图 解决方法 2,原因分析 这个与安全机制有关,默认情况下 ...
- 《Java开发学习大纲文档》V6.0(已经不公布了,请查看第七版)
<Java开发大纲学习文档第六版>简介: 有需要的私聊作者QQ:253173641.
- 基于innodb_print_all_deadlocks从errorlog中解析MySQL死锁日志
本文是说明如何获取死锁日志记录的,不是说明如何解决死锁问题的. MySQL的死锁可以通过show engine innodb status;来查看,但是show engine innodb statu ...
- echarts 设置数据加载遮罩层
//显示加载数据的loading chart.showLoading({ text: "图表数据正在努力加载...", x ...
- PTA变成总结1
1)实验代码 #include<stdio.h>int main(){ int N,k,n,i,j,p,m,ge; char op; while(1){ scanf("%d % ...
- Maven模块化开发
Maven模块化开发 多人协同开发时,特别是规模较大的项目,为方便日后代码维护管理会将每个人的工作细分到具体的功能和模块上.随着项目的不断扩大,模块会越来越多,后续更加难以维护和扩展,为应对这种情况后 ...