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

pytest运行_ios怎么清理应用缓存在哪里前言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怎么清理应用缓存在哪里

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

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


相关推荐

  • 在Laravel中使用数据库事务以及捕获事务失败后的异常

    在Laravel中使用数据库事务以及捕获事务失败后的异常

    2021年11月9日
    43
  • html实战-制作静态网页「建议收藏」

    html实战-制作静态网页「建议收藏」教程视频:http://edu.csdn.net/course/detail/535 从42开始制作的网页:http://www.cnos.co/整体思路:先布局再CSS控制骨架搭好了,初始化样式,后再弄CSS样式。注意:将CSS的样式导入到外部样式表时,要注意图片的位置,以及对外部样式表的引入  1、头部的背景图片的高度128px来自素材的图片高,容器的宽度大

    2025年9月15日
    6
  • 常用网管工具_网管系统

    常用网管工具_网管系统1、ping(你懂的)2、df-h(查看磁盘使用情况)3、top(查看cpu使用情况,按“1”可以查看各个cpu详情)4、pstree(树形显示进程及同名进程的数量)5、vmstat[m][n](显示服务器的CPU使用率,内存使用,虚拟内存交换情况,IO读写情况。间隔m秒钟显示一次,一共显示n次)6、nload(监视网络吞吐量)7、ps…|grep

    2022年10月6日
    1
  • MySQL触发器

    MySQL在5.0.2版本以上开始支持触发器,触发器是有某些带有命令的时间来触发某些操作,这些事件包括insert语句、delete语句、update语句等。触发器可以用于记录对数据库的操作。1、创

    2021年12月25日
    43
  • 建站指南和总结(期末总结)

    换了一个新的站点,Wordpress也没想象中的好用嘛

    2022年4月13日
    55
  • python取余什么意思_python中取余

    python取余什么意思_python中取余首先取响应头里的编码,如果是几种中文编码之一,则认为中文网页,如果不是中文编码,也不是几种unicode方案之一,则不是中文.否则再在标签里找charset,如果有并且为几种中文编码之一,则是中文如果不是中文编码,也不是几种unicode方案之一,则不是中文.否则对body的内容(如果考虑性能问题,可以不对整个body,只对前N个字节)用正则洗标签过滤所有ASCII码字符,剩余部分…

    2022年4月25日
    75

发表回复

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

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