pytest运行_ios怎么清理应用缓存在哪里

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


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怎么清理应用缓存在哪里

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/165144.html原文链接:https://javaforall.net

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


相关推荐

  • SDIO接口介绍_usb接口有几种规格

    SDIO接口介绍_usb接口有几种规格SDIO接口是在SD内存卡接口的基础上发展起来的接口,SDIO接口兼容以前的SD内存卡,并且可以连接SDIO接口的设备。SDIO1.0标准定义了两种类型的SDIO卡:1.全速的SDIO卡,传输率可以超过100Mbps;2.低速的SDIO卡,支援的时脉速率在0至400KHz之间。      SDIO协议是由SD卡的协议演化升级而来的,很多地方保留了SD卡的读写协议,同

    2022年10月4日
  • 【python】分苹果

    【python】分苹果问题:一堆苹果,5个人。第一个人将苹果丢掉一个,然后平均分成5份后拿走其中的一份;第二个人将剩余的苹果丢掉一个,然后再平均分成5份后拿走其中的一份,依次类推…第五个人在第四个人拿走剩下的那部分苹果中同样丢掉一个,然后平均分成5份后拿走其中的一份。求问最少的苹果数。depth=0defmatch(num):””””””globaldepth…

    2022年8月31日
  • MySql 三大日志:binlog、redo log 和 undo log

    点击上方“全栈程序员社区”,星标公众号 重磅干货,第一时间送达 Keeper导读:日志是mysql数据库的重要组成部分,记录着数据库运行期间各种状态信息。mysql日志主要包括错误…

    2021年6月24日
  • AWK awk xxx xxx[通俗易懂]

    AWK awk xxx xxx[通俗易懂]awk’BEGIN{a=5;a+=5;printa}’10

    2022年8月22日
  • Windows7 64位系统搭建Cocos2d-x 2.2.1最新版以及Android交叉编译环境(具体教程)

    Windows7 64位系统搭建Cocos2d-x 2.2.1最新版以及Android交叉编译环境(具体教程)

    2021年11月30日
  • 清除浏览器缓存(js、css等)

    清除浏览器缓存(js、css等)有时候写web项目,改了js或者css文件,但是浏览器就是不刷新,就很头疼o(╥﹏╥)o。那是因为浏览器还有缓存存在的原因,下面来看如何清除缓存。1.找到目标网页,鼠标右击,点击检查;或者Ctrl+Shift+i;进入检查界面(我用的是谷歌浏览器)。2.点击Network,然后选择要清除什么文件(js、css等等)的缓存,当然也可以选择All,这样就全部加载出来了3.如果没有东西出来,就刷新一次网页,然后找到你的目标文件,右击,选择Clearbrowsercashe清..

    2022年7月18日

发表回复

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

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