- 转到项目源
- 运行
py.test --pep8 --junitxml=pep8.log
第一个控制台显示 pytest 已经测试过的 .py 文件,然后它会显示一条消息:
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 文件的其他行上继续失败。
我认为有一种更好的方法可以全局修复此问题,然后编辑它失败的每一行代码。
请您参考如下方法:
我为 pytest 开发人员提交了一个问题并已修复 https://bitbucket.org/hpk42/pytest/issue/368/unicode-error-when-launching-pytest
