【发布时间】:2013-10-11 09:01:57
【问题描述】:
- 转到项目源
- 运行
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 文件的其他行上继续失败。
我认为有一种更好的方法来全局解决这个问题,然后编辑它失败的每一行代码。
【问题讨论】:
-
找到了解决方法:bitbucket.org/apkawa/pytest/commits/… 但现在它在 py 包中失败:文件“C:\Python27\lib\site-packages\py_xmlgen.py”,第 133 行,在 __object self.write (escape(unicode(obj))) UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 1305: ordinal not in range(128)
-
我向 oytest 开发者提交了一个问题,并已修复:bitbucket.org/hpk42/pytest/issue/368/…
-
如果您已经回答了自己的问题,也许您可以写一个答案并接受它?这将使问题显示为“已回答”。
标签: python unicode utf-8 pep8 pytest