Pytest在Unicode中无法生成XML输出

德米特里·格卢申科夫(Dmitry Glushonkov)
  1. 转到项目src
  2. py.test --pep8 --junitxml=pep8.log

第一个控制台显示已经测试过的.py文件pytest,然后显示一条消息:

INTERNALERROR>   File "C:\Python27\lib\site-packages\_pytest\junitxml.py", line 134, in append_failure
INTERNALERROR>     fail.append(str(report.longrepr))
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 1430-1434: ordinal not in range(128)

我试图通过转换fail.append(str(report.longrepr))来解决此问题,fail.append(str(report.longrepr.encode("utf-8")))但pytest在此文件和_xmlgen.py文件的其他行上仍然失败。

我认为,有一种更好的方法可以在全局范围内修复此问题,然后再对其失败的每一行代码进行编辑。

德米特里·格卢申科夫(Dmitry Glushonkov)

我向pytest开发人员提出了一个问题,该问题已修复https://bitbucket.org/hpk42/pytest/issue/368/unicode-error-when-launching-pytest

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章