分享

python笔记31-ddt报告优化

 上海悠悠 2021-05-27

前言

使用ddt框架生成html报告的时候出现dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) ->

遇到问题

使用ddt框架生成html报告的时候,出现:dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s (key, value) pairs dict(iterable) ->

出现这个问题主要是新版本的ddt框架的一个BUG

解决办法

使用pip show查看ddt版本号Version: 1.2.0

pip show ddt

Name: ddt Version: 1.2.0 Summary: Data-Driven/Decorated Tests Home-page: https://github.com/txels/ddt Author: Carles Barrobés Author-email: carles@barrobes.com License: UNKNOWN Location: d:\soft\python3.6\lib\site-packages Requires: Required-by:

先使用pip uninstall ddt载了,再重新一点的ddt版本就好了,指定版本号用两个等号,后面接对应版本号即可

pip uninstall ddt
pip install ddt==1.1.2

接下来重新运行代码,生成的报告就可以正常的展示出中文的内容了

对比源码

Version: 1.1.2源码

Version: 1.2.0源码

通过对比2个版本的源码,发现里面少一行代码:testdocstring = getattr(v, “_doc“, None)

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约