2013-10-04 16 views
2
  1. 转到项目SRC
  2. 运行py.test --pep8 --junitxml=pep8.log

首先控制台显示pytest已经测试.py文件,比刹车,提示信息:Pytest不能生成XML输出时使用Unicode

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文件的其他行上继续失败。

我认为有一个更好的方法来解决这个全局然后编辑它的每一行代码失败。

+0

此找到的解决办法:https://bitbucket.org/apkawa/pytest/commits/1a284b99104e2d525b46a13a0fffff081158377a但现在它在PY包失败:文件“C :\ Python27 \ lib \ site-packages \ py \ _xmlgen.py“,第133行,在__object self.write(escape(unicode(obj))) UnicodeDecodeError:'ascii'编解码器无法解码字节0xd0的位置1305:序号不在范围内(128) –

+0

我向oytest开发者提交了一个问题,它已修复:https://bitbucket.org/hpk42/pytest/issue/368/unicode-error-when-launching-pytest –

+0

如果您回答了你自己的问题,也许你可以写一个答案并接受它?这将允许问题显示为“已回答”。 –

回答