使用多个fixture和fixture直接互相调用
使用多个fixture
如果用例需要用到多个fixture的返回数据,fixture也可以return一个元组、list或字典,然后从里面取出对应数据。
# test_fixture4.py
import pytest @pytest.fixture()
def user():
print("获取用户名")
a = "yoyo"
b = ""
return (a, b) def test_1(user):
u = user[]
p = user[]
print("测试账号:%s, 密码:%s" % (u, p))
assert u == "yoyo" if __name__ == "__main__":
pytest.main(["-s", "test_fixture4.py"])
当然也可以分开定义成多个fixture,然后test_用例传多个fixture参数
# test_fixture5.py
import pytest @pytest.fixture()
def user():
print("获取用户名")
a = "yoyo"
return a @pytest.fixture()
def psw():
print("获取密码")
b = ""
return b def test_1(user, psw):
'''传多个fixture'''
print("测试账号:%s, 密码:%s" % (user, psw))
assert user == "yoyo" if __name__ == "__main__":
pytest.main(["-s", "test_fixture5.py"])
fixture与fixture互相调用
fixture与fixture直接也能互相调用的
import pytest @pytest.fixture()
def first():
print("获取用户名")
a = "yoyo"
return a @pytest.fixture()
def sencond(first):
'''psw调用user fixture'''
a = first
b = ""
return (a, b) def test_1(sencond):
'''用例传fixture'''
print("测试账号:%s, 密码:%s" % (sencond[], sencond[])) assert sencond[] == "yoyo" if __name__ == "__main__":
pytest.main(["-s", "test_fixture6.py"])
使用多个fixture和fixture直接互相调用的更多相关文章
- pytest文档23-使用多个fixture和fixture直接互相调用
使用多个fixture 如果用例需要用到多个fixture的返回数据,fixture也可以return一个元组.list或字典,然后从里面取出对应数据. # test_fixture4.py impo ...
- fitnesse 中各类fit fixture的python实现
虽然网上都说slim效率很高,无奈找不到支持python的方法,继续用pyfit 1 Column Fixture 特点:行表格展现形式,一条测试用例对应一行数据 Wiki !define COMMA ...
- pytest进阶之fixture
前言 学pytest就不得不说fixture,fixture是pytest的精髓所在,就像unittest中的setup和teardown一样,如果不学fixture那么使用pytest和使用unit ...
- 单元测试之Fixture
声明: 作者:zhaojun 创建日期:2017-08-04 更新日期:2017-08-07 一.什么是Fixture,Fixture有什么作用,为什么需要使用Fixture # 下载 pip i ...
- Pytest高级进阶之Fixture
From: https://www.cnblogs.com/feiyi211/p/6626314.html 一. fixture介绍 fixture是pytest的一个闪光点,pytest要精通怎么能 ...
- pytest框架之fixture详细使用
本人之前写了一套基于unnitest框架的UI自动化框架,但是发现了pytest框架之后觉得unnitest太low,现在重头开始学pytest框架,一边学习一边记录,和大家分享,话不多说,那就先从p ...
- pytest.5.参数化的Fixture
From: http://www.testclass.net/pytest/parametrize_fixture/ 背景 继续上一节的测试需求,在上一节里,任何1条测试数据导致断言不通过后测试用例就 ...
- pytest.4.Fixture
From: http://www.testclass.net/pytest/fixture/ 我们可以简单的把Fixture理解为准备测试数据和初始化测试对象的阶段. 一般我们对测试数据和测试对象的管 ...
- Pytest - 进阶功能fixture
1. 概述 Pytest的fixture功能灵活好用,支持参数设置,便于进行多用例测试,简单便捷,颇有pythonic.如果要深入学习pytest,必学fixture. fixture函数的作用: 完 ...
随机推荐
- tornada-基础
回想Django的部署方式 以Django为代表的python web应用部署时采用wsgi协议与服务器对接(被服务器托管),而这类服务器通常都是基于多线程的,也就是说每一个网络请求服务器都会有一个对 ...
- ffmpeg函数02__swr_alloc_set_opts()
SwrContext *swr_alloc(void); // 分配重采样的上下文. SwrContext *swr_alloc_set_opts(struct SwrContext *s, int ...
- vue中的各种属性
data new vue({ data:{ 'a':1 } }) 是一个实例,data直接是一个对象 vue.component('my',{ template:'', props:['title'] ...
- ubuntu桌面最大化
三行命令搞定Ubuntu 16.04下安装VMware Tools!!!!!!!!! 由于下载的是ubuntu-16.04.3-desktop-amd64,需要安装vmware tools,以往提取的 ...
- 如何在输入命令行npm run dev 之后vue项目自动在浏览器打开
使用代码编辑器打开vue项目代码,在config文件夹里面找到index.js 将里面的:autoOpenBrowser: false, 修改为 :autoOpenBrowser: true, 这个方 ...
- Oracle体系结构2
Buffer Cache 作用:缓存dbf中的数据 例子:A和B重复访问同一张表的几率是很大的,如果每次访问dbf时都要发生物理IO,这样会导致数据库的性能非常低 由于这个例子,当一个进程访问dbf时 ...
- cursor(鼠标手型)属性
㈠简单介绍 在浏览网页时,通常看到的鼠标光标形状有箭头.手形.沙漏等,而在 windows 中实际看到的鼠标指针种类比这个还要多. 一般情况下,鼠标光标的形状由浏览器负责控制,大多数情况的光标形状为箭 ...
- 1、布局容器Grid、StackPanel、GroupBox、DockPanel、WrapPanel
Grid——网格布局,其中控件或容器需指定位置 StackPanel——堆叠面板,其中的控件水平布局.竖直布局 DockPanel——停靠面板,内部控件或容器可以放置在上.下.左.右 WrapPane ...
- [模板] KMP算法/Border
KMP 算法 KMP (Knuth-Morris-Pratt) 算法是一种在线性时间内匹配文本串和模式串的算法. 称字符串的 Border 集合为 \[ \operatorname {Border} ...
- PHP 下载+安装
1.官网下载 官网地址:http://PHP.net/ 地址:http://download.csdn.NET/detail/anndy_/9494632 官网手册:https://secure.ph ...