pytest运行_安卓手机缓存怎么清理

pytest运行_安卓手机缓存怎么清理前言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运行_安卓手机缓存怎么清理

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

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


相关推荐

  • 用IDEA一年了,终于敢说自己会用了(IDEA配置和使用)[通俗易懂]

    作为Java老兵,我也是用了很多年的eclipse,为了与时俱进,于是切换到了IDEA。刚开始的时候感觉很不适应,感觉这玩意儿不如eclipse好用,影响工作效率,于是又换回eclipse。但是很多

    2022年2月16日
    47
  • 狄利克雷近似定理_莫比乌斯反演例题

    狄利克雷近似定理_莫比乌斯反演例题首先定义几个概念:1,卷积:设是两个数论函数(也就是说,以自然数集为定义域的复数值函数),则卷积运算定义为可以证明,卷积运算满足:1)交换律:由定义显然。2)结合律:考察两边作用在上,左边是右边是故两边相等。3)存在单位元使得我们需要故不难猜到应该定义为事实上,直接验证可得以上说明数论函数在卷积意义下构成一个交换群。

    2025年7月6日
    2
  • conda安装Pytorch下载过慢解决办法(11月26日更新ubuntu下pytorch1.3安装方法)

    conda安装Pytorch下载过慢解决办法(11月26日更新ubuntu下pytorch1.3安装方法)目录添加清华源安装PyTorch3月5日更新ubuntu下pytorch1.0.1安装方法(Ubuntu16.04+CUDA9.0+PyTorch1.0.1)7月23日更新ubuntu下pytorch1.1安装方法(通过pip)11月26日更新ubuntu下pytorch1.3安装(通过conda)pytorch最近已经更新到了稳定版本的1.0.1,从Pytorch官网上可…

    2022年6月24日
    64
  • navicat premium mac 激活码【最新永久激活】

    (navicat premium mac 激活码)本文适用于JetBrains家族所有ide,包括IntelliJidea,phpstorm,webstorm,pycharm,datagrip等。IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月27日
    145
  • ov7740摄像头参数_ov7670摄像头使用手册

    ov7740摄像头参数_ov7670摄像头使用手册之前调过一款摄像头,是MT9V034,最近在调的是OV7725摄像头,感觉OV7725摄像头比MT9V034要难,特别是寄存器配置,要想玩转一款摄像头,必须要熟悉它的寄存器配置,而且要亲自去调试,然后才能对它有很好的理解。下面是自己的一点见解,可能不完全对,不过希望对初学者有所帮助吧。一、将所有寄存器的值复位到默认值状态。  寄存器地址   寄存器名称   寄存器值

    2022年9月23日
    2
  • JSONObject转换为JSONArray

    JSONObject转换为JSONArray一.JSONObject转JSONArray//json串内容如下{“request_id”:”1111111111112″,”audience”:[“aaa”,”bbb”],”settings”:{“ttl”:36000000,”strategy”:{“default”:3,”ios”:4}}}以com.alibaba.fastjson中的JSONAr

    2022年5月27日
    31

发表回复

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

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