pytest框架(一)

代码示例一
# coding=utf-8 def func(x):
return x + 1 def test_answer():
assert func(3) == 5
运行结果
E:\pyYouYou\pytest_demo>pytest test_sample.py
============================= test session starts =============================
platform win32 -- Python 3.6.1, pytest-3.7.2, py-1.5.4, pluggy-0.7.1
rootdir: E:\pyYouYou\pytest_demo, inifile:
collected 1 item test_sample.py F [100%] ================================== FAILURES ===================================
_________________________________ test_answer _________________________________ def test_answer():
> assert func(3)==5
E assert 4 == 5
E + where 4 = func(3) test_sample.py:7: AssertionError
示例代码二
# coding=utf-8 class TestClass:
def test_one(self):
x = "this"
assert 'h' in x def test_two(self):
x = "hello"
assert hasattr(x, 'check')
运行结果
E:\pyYouYou\pytest_demo>py.test -q test_class.py
.F [100%]
================================== FAILURES ===================================
_____________________________ TestClass.test_two ______________________________ self = <pyYouYou.pytest_demo.test_class.TestClass object at 0x0000000002C319E8> def test_two(self):
x = "hello"
> assert hasattr(x, 'check')
E AssertionError: assert False
E + where False = hasattr('hello', 'check') test_class.py:10: AssertionError
1 failed, 1 passed in 0.10 seconds
pytest框架(一)的更多相关文章
- pytest框架之fixture详细使用
本人之前写了一套基于unnitest框架的UI自动化框架,但是发现了pytest框架之后觉得unnitest太low,现在重头开始学pytest框架,一边学习一边记录,和大家分享,话不多说,那就先从p ...
- Appium 并发多进程基于 Pytest框架
前言: 之前通过重写unittest的初始化方法加入设备参数进行并发,实现了基于unittest的appium多设备并发,但是考虑到unittest的框架实在过于简陋,也不方便后期的Jenkins的持 ...
- pytest 框架自动化Selenium 之yield 使用
环境 python 3.7 由于3.0-3.5以下部分pytest可能有部分兼容问题安装建议2.7-2.9,3.5-最新 pip install pytest专属 pytest框架包 pip inst ...
- Pytest框架介绍
Pytest框架介绍.安装 pytest是python测试框架,与python自带的unittest测试框架类似,但是比unittest框架使用起来更简洁,功能更强大 pytest特征 1:断言提示信 ...
- pycharm中脚本执行的3种模式(unittest框架、pytest框架、普通模式)
背景知识,某次使用HTMLTestRunner的时候,发现一直都无法导出报告,后来查询资料发现了一些坑,现在整理一下来龙去脉. 一:pycharm默认的是pytest框架去执行unittest框架的测 ...
- pytest框架之rerunfailures失败重运行机制
web自动化测试中,稳定性在整个测试运行中都至关重要,但不能保证测试脚本或者测试环境一直都能够稳定,它牵扯到诸多因素,在这里就不赘述,pytest框架相较于unittest的一大优势就在于拥有用例失败 ...
- 【Pytest01】全网最全最新的Pytest框架快速入门
一.Pytest简介pytest是一个非常成熟的全功能的Python测试框架,主要有一下几个特点:1.简单灵活,容易上手,支持参数化2.能够支持简单的单元测试和复杂的功能测试,还可以用来做seleni ...
- pytest框架使用教程
Pytest框架 一.简介 pytest:基于unittest之上的单元测试框架 有什么特点? 自动发现测试模块和测试方法 断言更加方便,assert + 表达式,例如 assert 1 == 1 灵 ...
- pytest框架的安装与使用
pytest框架的安装与使用 一,pytest了解 pytest是python的一种单元测试框架,与python自带的unittest测试框架类似,但是比unittest框架使用起来更简洁,效率更高. ...
- pytest框架执行自动化测试时使用pycharm正常运行,使用cmd或Terminal报错:Hint: make sure your test modules/packages have valid Python names.
问题描述: 使用pytest框架做接口自动化测试时,在测试用例所在的.py文件下使用pycharm的run功能可以正常跑用例,使用cmd运行窗口或Terminal则报下图中的错误: Hint: mak ...
随机推荐
- 【转】如何让虚拟目录里面的webconfig不继承网站的设置
[转]http://www.cnblogs.com/Sue_/articles/2037556.html 必須在上一层虚拟目录(如根目录)所在的Web.config加上 如:<location ...
- win10专业版激活(亲测可用)
1.slmgr.vbs /upk 2.slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX 3.slmgr /skms zh.us.to 4.slmgr /ato
- BZOJ 1629 [Usaco2005 Nov]Cow Acrobats:贪心【局部证明】
题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1332 题意: 有n头牛在“叠罗汉”. 第i头牛的体重为w[i],力量为s[i]. 一头 ...
- RQNOJ 117 最佳课题选择:多重背包
题目链接:https://www.rqnoj.cn/problem/117 题意: NaCN_JDavidQ要在下个月交给老师n篇论文,论文的内容可以从m个课题中选择. 由于课题数有限,NaCN_JD ...
- jsp参数传递
jsp参数传递 jsp中四种传递参数的方法 1.form表单 2.request.setAttribute();和request.getAttribute(); 3.超链接:<a herf=&q ...
- JS遍历ChexkBoxList
var cboxs = $("#cblAuth input[type=checkbox]"); ; ; i < cboxs.length; i++) { if (cboxs[ ...
- 【Codeforces】Gym 101156E Longest Increasing Subsequences LIS+树状数组
题意 给定$n$个数,求最长上升子序列的方案数 根据数据范围要求是$O(n\log n)$ 朴素的dp方程式$f_i=max(f_j+1),a_i>a_j$,所以记方案数为$v_i$,则$v_i ...
- SoundHound Inc. Programming Contest 2018
A - F Time Limit: 2 sec / Memory Limit: 1024 MB Score : 100100 points Problem Statement You are give ...
- poj3017 Cut the Sequence[平衡树+单调队列优化]
这里已经讲得很清楚了. 本質上是決策點與區間最大值有一定關係,於是用单调队列来维护决策集合(而不是常规的),然后在决策集合中选取最小值. 然后觉得这题方法还是很重要的.没写平衡树,用优先队列(堆)来维 ...
- 设计四个线程,其中两个线程每次对j加1,另外两个线程每次对j减1
public class ManyThreads2 { private int j = 0; public synchronized void inc() { j++; System.out.prin ...