配置为测试结果显示的符号

pytest-custom-report的Python项目详细描述


travispypipyversions

https://user-images.githubusercontent.com/6615374/44383803-a48a7600-a4df-11e8-9ce5-dfd5eca9d208.png

pytest自定义报告

一个插件,用于定义在pytest中显示测试结果时要使用的自己的字符(通过、失败、跳过等)。

例如,如果希望在每个失败测试的终端报告中显示PILE OF POO (U+1F4A9)标志符号:

pytest --report-failed=?

若要保留自定义字符,请在configuration file(即在pytest.initox.inisetup.cfg或其他位置)中添加类似的节:

[pytest]
report_failed = ?
report_failed_verbose = OH CRAP

安装和使用

pip install pytest-custom-report

这将向pytest添加新的命令行参数和配置文件选项(详细信息请参见下一节)。命令行参数优先于配置文件设置。插件总是启用的,但是除非您配置了自己的符号,否则将使用pytest默认值。

要在暂时禁用插件的情况下执行测试,请使用以下命令:

pytest -p no:pytest-custom-report

如果您尝试使用emojis,但在终端中看不到标志符号,则可能缺少带有上平面的unicode字体-您可以安装例如GNU Unifont

配置

下表显示了每个结果的可用选项以及pytest的默认样式。

test outcomecommand-line argument name.ini file config keydefault report symbol
^{tt7}$^{tt8}$^{tt9}$^{tt10}$
^{tt11}$^{tt12}$^{tt13}$^{tt14}$
^{tt15}$^{tt16}$^{tt17}$^{tt18}$
^{tt19}$^{tt20}$^{tt21}$^{tt22}$
^{tt23}$^{tt24}$^{tt25}$^{tt26}$
^{tt27}$^{tt28}$^{tt29}$^{tt30}$

当在启用-v--verbose标志的情况下执行测试时,将显示更长的字符串,每个测试结果显示一行。这些也可以指定。

test outcomecommand-line argument name.ini file config keydefault report string
^{tt7}$^{tt34}$^{tt35}$^{tt36}$
^{tt11}$^{tt38}$^{tt39}$^{tt40}$
^{tt15}$^{tt42}$^{tt43}$^{tt44}$
^{tt19}$^{tt46}$^{tt47}$^{tt48}$
^{tt23}$^{tt50}$^{tt51}$^{tt52}$
^{tt27}$^{tt54}$^{tt55}$^{tt56}$

示例配置文件

下面是一些示例pytest.ini内容,您可以根据自己的喜好复制粘贴和修改:

[pytest]

report_passed = ✔
report_xpassed = ?
report_failed = ✗
report_xfailed = ?
report_skipped = ?
report_error = ?

report_passed_verbose = OH YEAH
report_xpassed_verbose = WHAT IN TARNATION?
report_failed_verbose = OH CRAP
report_xfailed_verbose = YEAH WHATEVER
report_skipped_verbose = DON'T CARE
report_error_verbose = YOU MEDDLING KIDS!
https://user-images.githubusercontent.com/6615374/44383928-02b75900-a4e0-11e8-9d81-84c0d2b14155.png

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何反射地迭代数组字段?   java NamedQuery错误“具有给定标识符的多行:1”   java无法使用单独类中的计时器更新TextView   兼容性什么时候可以很快使用新的Java功能?   java二叉树路径和   java矩形的性能   java我想从同一个子表在主表中添加两个外键   java如何获取基于特定日期的所有数据?   java javafx、OO编程规则和写入变量类型的选择   java使用带枚举的switch语句   java异步任务生成运行时异常   java为什么JLabel不显示下划线字符?   java如何解析具有可变参数号的函数?   带有按钮的java JavaFX自定义列表单元格:未调用处理程序   java Modelmapper无法映射整个模型?   传递给持久化的java分离实体,包含LatLng列表