08、分析测试执行时间及获取pytest帮助

官方用例

python 复制代码
# content of test_slow_func.py
import pytest
from time import sleep

@pytest.mark.parametrize('delay',(1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.0,0.1,0.2,0,3))
def test_slow_func(delay):
    print("test_slow_func {}".format(delay))
    sleep(delay)
    assert 1

解读与实操

  • 查询pytest版本号
  • 查询所有pytest的fixture
  • 查询所有pytest的帮助

应用场景

  • 遇到新场景,想查看下pytest中是否有相应实现。
  • 看到其他人使用了某个特性,要了解相关用法

以上两种场景,都可以通过pytest -h 帮助,要查询或了解。

相关推荐
姚青&3 天前
PyCharm 配置与界面化运行
pytest
姚青&3 天前
Pytest 测试用例断言
测试用例·pytest
姚青&3 天前
Pytest 命名规则
pytest
姚青&3 天前
Pytest 测试用例结构
测试用例·pytest
姚青&4 天前
Pytest 简介、安装与环境准备
pytest
测试渣4 天前
持续集成中的自动化测试框架优化实战指南
python·ci/cd·单元测试·自动化·pytest
小凯123455 天前
pytest框架-详解(学习pytest框架这一篇就够了)
python·学习·pytest
逻极5 天前
pytest 入门指南:Python 测试框架从零到一(2025 实战版)
开发语言·python·pytest