Python Pytest文档用例规则

Time will tell.一、用例设计原则文件名以test_*.py文件和*_test.py以test_开头的函数以Test开头的类以test_开头的方法所有的包 pakege 必须要有__init__.py文件二、help帮助查看 pytest 命令行参数,可以用pytest -h或pytest —help查看。C:\Users\admin>pytest -husage: pytest [options] [file_or_dir] [file_or_dir] [...
摘要由CSDN通过智能技术生成

Time will tell.

一、用例设计原则

文件名以test_*.py文件和*_test.py

  • test_开头的函数
  • Test开头的类
  • test_开头的方法
  • 所有的包 pakege 必须要有__init__.py文件

二、help帮助

查看 pytest 命令行参数,可以用pytest -hpytest —help查看。

C:\Users\admin>pytest -h
usage: pytest [options] [file_or_dir] [file_or_dir] [...]

positional arguments:
  file_or_dir

general:
  -k EXPRESSION         only run tests which match the given substring
                        expression. An expression is a python evaluatable
                        expression where all names are substring-matched
                        against test names and their parent classes. Example:
                        -k 'test_method or test_other' matches all test
                        functions and classes whose name contains
                        'test_method' or 'test_other', while -k 'not
                        test_method' matches those that don't contain
                        'test_method' in their names. Additionally keywords
                        are matched to classes and functions containing extra
                        names in their 'extra_keyword_matches' set, as well as
                        functions which have names assigned directly to them.
  -m MARKEXPR           only run tests matching given mark expression.
                        example: -m 'mark1 and not mark2'.
  --markers             show markers (builtin, plugin and per-project ones).
  -x, --exitfirst       exit instantly on first error or failed test

reporting:
  -v, --verbose         increase verbosity.
  -q, --quiet           decrease verbosity.
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值