pytest运行_怎么清理ios文件app的缓存

pytest运行_怎么清理ios文件app的缓存前言pytest运行完用例之后会生成一个.pytest_cache的缓存文件夹,用于记录用例的ids和上一次失败的用例。方便我们在运行用例的时候加上–lf和–ff参数,快速运行上一

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

前言

pytest 运行完用例之后会生成一个 .pytest_cache 的缓存文件夹,用于记录用例的ids和上一次失败的用例。
方便我们在运行用例的时候加上–lf 和 –ff 参数,快速运行上一次失败的用例。
–lf, –last-failed 只重新运行上次运行失败的用例(或如果没有失败的话会全部跑)
–ff, –failed-first 运行所有测试,但首先运行上次运行失败的测试(这可能会重新测试,从而导致重复的fixture setup/teardown)
 

cache

pytest -h 查看命令行参数,关于 cache 参数的使用方式

> pytest -h

--lf, --last-failed   rerun only the tests that failed at the last 
                      run (or all if none failed)
--ff, --failed-first  run all tests, but run the last failures first.
                      This may re-order tests and thus lead to repeated fixture                                   											setup/teardown.
--nf, --new-first     run tests from new files first, then the rest of the tests sorted by 												file mtime
--cache-show=[CACHESHOW]
                      show cache contents, don't perform collection or tests. Optional      											argument: glob(default: '*').
--cache-clear         remove all cache contents at start of test run.

参数说明:

  • –lf 也可以使用 --last-failed 仅运行上一次失败的用例
  • –ff 也可以使用 --failed-first 运行全部的用例,但是上一次失败的用例先运行
  • –nf 也可以使用 --new-first 根据文件插件的时间,新的测试用例会先运行
  • –cache-show=[CACHESHOW] 显示.pytest_cache文件内容,不会收集用例也不会测试用例,选项参数: glob (默认: ‘*’)
  • –cache-clear 测试之前先清空.pytest_cache文件
     

–cache-show

案例

def test_01():
    a = "hello"
    b = "hello"
    assert a == b


def test_02():
    a = "hello"
    b = "hello world"
    assert a == b


def test_03():
    a = "hello"
    b = "hello world"
    assert a in b


def test_04():
    a = "hello"
    b = "hello world"
    assert a not in b

命令行输入 运行完成后,会有2个用例失败,2个用例成功

collecting ... 
 case/test_1.py ✓                                                                                                                                                                                         25% ██▌       

 case/test_1.py ⨯✓                                                                                                                                                                                        75% ███████▌  

 case/test_1.py ⨯                                                                                                                                                                                        100% ██████████

运行完成后,会在当前的目录生成一个 .pytest_cache 的缓存文件夹,层级结构如下

pytest运行_怎么清理ios文件app的缓存

lastfailed 文件记录上一次运行失败的用例

{
  "test_x.py::test_02": true,
  "test_x.py::test_04": true
}

nodeids 文件记录所有用例的节点

[
  "test_x.py::test_01",
  "test_x.py::test_02",
  "test_x.py::test_03",
  "test_x.py::test_04"
]

于是可以通过 pytest –cache-show 命令查看cache目录

(pytest_env) ➜  apiAutomatic pytest --cache-show
Test session starts (platform: darwin, Python 3.7.6, pytest 6.2.1, pytest-sugar 0.9.4)
rootdir: /Users/jkc/PycharmProjects/apiAutomatic, configfile: pytest.ini
plugins: assume-2.4.2, sugar-0.9.4, rerunfailures-9.1.1, base-url-1.4.2, html-3.1.1, metadata-1.11.0, ordering-0.6, cov-2.10.1, repeat-0.9.1, xdist-2.2.0, forked-1.3.0, allure-pytest-2.8.29
cachedir: /Users/jkc/PycharmProjects/apiAutomatic/.pytest_cache
------------------------------------------------------------------------------------------------- cache values for '*' -------------------------------------------------------------------------------------------------
cache/lastfailed contains:
  {'case/test_1.py::test_02': True, 'case/test_1.py::test_04': True}
cache/nodeids contains:
  ['case/test_1.py::test_01',
   'case/test_1.py::test_02',
   'case/test_1.py::test_03',
   'case/test_1.py::test_04']
cache/stepwise contains:
  []
Results (0.02s):

 

–cache-clear

–cache-clear 用于在测试用例开始之前清空cache的内容

查看pytest关于cache的更多文档https://docs.pytest.org/en/latest/cache.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/166363.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 51Nod 1593 公园晨跑(RMQ,ST表)

    51Nod 1593 公园晨跑(RMQ,ST表)

    2021年7月3日
    107
  • 修改Matlab的背景颜色

    修改Matlab的背景颜色网上的教程基本是修改prf文件或者输入一串命令其实使用界面操作就可以改变背景颜色步骤点击主页—>预设(预设在布局右边)点击颜色,出现以下界面。在这里,默认是勾选“使用系统颜色”的。我们把这一项取消勾选!取消勾选以后,“文本”和“背景”就变成可点击的状态,点击“背景”—>“更多颜色”在RGB这一栏输入护眼色的参数,R:199,G:237,B:2…

    2022年6月20日
    107
  • 防火墙透明模式和路由模式区别_防火墙的部署模式

    防火墙透明模式和路由模式区别_防火墙的部署模式防火墙能够工作在三种模式下:路由模式、透明模式、混合模式。如果防火墙以第三层对外连接(接口具有IP地址),则认为防火墙工作在路由模式下;若防火墙通过第二层对外连接(接口无IP地址),则防火墙工作在透明模式下;若防火墙同时具有工作在路由模式和透明模式的接口(某些接口具有IP地址,某些接口无IP地址),则防火墙工作在混合模式下。防火墙三种工作模式的简介1、路由模式当防火墙位于内部网络和外部网络之间时,需要将防火墙与内部网络、外部网络以及DMZ三个区域相连的接口分别配置成不同网段的IP地址

    2025年8月10日
    2
  • Tomcat下载——tomcat7、tomcat8、tomcat9官网下载链接

    Tomcat下载——tomcat7、tomcat8、tomcat9官网下载链接1.官网下载链接:https://tomcat.apache.org2.选择Download——>tomcat7/8/9,如下图所示:3.选择32/64位相应下载。4.下载好的zip包进行解压缩即可。…

    2022年5月19日
    45
  • spring beanutils.copyproperties_bean property

    spring beanutils.copyproperties_bean property背景最近项目中在和第三方进行联调一个接口,我们这边发送http请求给对方,然后接收对方的回应,代码都是老代码。根据注释,对方的SDK中写好的Request类有一个无法序列化的bug,所以这边重新写了一个Request类,基本属性都是相同的,但是重点是有一个属性是静态内部类,还有两个是list属性,类似于下面这样:privateListorders;privateAddRequest.Tick…

    2022年9月27日
    2
  • ros的安装教程_ROS教程

    ros的安装教程_ROS教程总结一下这两天安装ROS的过程。1配置软件库桌面左侧栏点searchyourcomputer,输入updates,点Software&Updates,将main,universe,multiuniverse,restricted全都勾上,将Downloadfrom换成中科大的http://mirrors.ustc.edu,cn/ubuntu2…

    2025年10月22日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号