; ;
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 27 下一页
摘要: pytest中使用fixture装饰器是来固定的工厂函数,fixture函数可以在测试执行前和执行后进行必要的准备和清理工作 1. fixture做为函数引用使用 比如以下 import pytest # fixture作为函数引用 @pytest.fixture() def before(): p 阅读全文
posted @ 2020-04-04 22:16 做梦的人- 阅读(276) 评论(0) 推荐(0)
摘要: 使用pytest控制函数运行的函数 需要使用 (1)使用 @pytest.mark.run(order=x) 标记被测试函数 (2)运行的顺序由order传入的参数决定;(order从小到大的顺序执行) import pytest class Calc(object): @classmethod d 阅读全文
posted @ 2020-04-04 16:35 做梦的人- 阅读(1507) 评论(0) 推荐(0)
摘要: 背景: 在pycharm中运行正常,但是使用命令方式就提示没有模块 解决方案 在Python安装目录下的\Lib\site-packages文件夹中建立一个.pth文件,内容为自己写的 查看包是否有导入 再次运行,就成功了 阅读全文
posted @ 2020-04-01 23:05 做梦的人- 阅读(6065) 评论(0) 推荐(0)
摘要: 背景:一些数据在redis中会生成多条数据,如果想保持环境的干净,每次都要手动清除,很费事,使用shell脚本批量删除满足条件的key,key是模糊查询的 redis_comm=/home/zhangjun/redis-cli redis_ser01=172.19.XX.30 redis_ser02 阅读全文
posted @ 2020-03-21 15:05 做梦的人- 阅读(1667) 评论(0) 推荐(0)
摘要: pytest 生成报告,需要提前安装插件 pip install pytest-html 使用方式: 在运行时使用--html=report.html (report就是生成html的文件名) eg:pytest test_rundemo.py --html=reportdemo.html 测试案例 阅读全文
posted @ 2020-03-17 22:18 做梦的人- 阅读(1208) 评论(0) 推荐(0)
摘要: pytest有几种运行方式 1.全量方式运行 pytest 测试py文件 2.部分方法运行 pytest test_mod.py::test_func 3.运行时显示详细日志 pytest test_mod.py::test_func -v -s 案例展示 全量方式运行 def test_demo1 阅读全文
posted @ 2020-03-17 22:07 做梦的人- 阅读(1952) 评论(0) 推荐(0)
摘要: 使用ddt,要使用ppt可以使用下面命令进行安装 pip install ddt ddt就是做一个数据驱动而做,下面就是一个简单的案例,进行数据驱动,在后面做了一个断言 import unittest import ddt @ddt.ddt class Praddt(unittest.TestCas 阅读全文
posted @ 2020-03-15 22:12 做梦的人- 阅读(901) 评论(0) 推荐(0)
摘要: 使用HtmlTestRunner 显示报告 # coding=utf-8 import unittest import HTMLTestRunner import math class Calc(object): def add(self, x, y, *d): # 加法计算 result = x 阅读全文
posted @ 2020-03-15 21:54 做梦的人- 阅读(745) 评论(0) 推荐(0)
摘要: unittest中包含了很多断言内容,实际用到的断言内容也就比对值是否相同,下面是unittest中的断言内容 #encoding=utf-8 import unittest import random # 被测试类 class MyClass(object): @classmethod def s 阅读全文
posted @ 2020-03-15 21:42 做梦的人- 阅读(562) 评论(0) 推荐(0)
摘要: 背景:在执行单元测试中,有些方法执行耗时,不想全部执行,想忽略执行,那就需要跳过某方法执行 1.无条件跳过某方法 @unittest.skip("skipping") 2.使用变量的方式,指定忽略测试方法 a=10 @unittest.skipIf(a > 5, "condition is not 阅读全文
posted @ 2020-03-15 21:33 做梦的人- 阅读(1252) 评论(0) 推荐(0)
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 27 下一页