2013-10-04 14 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

如果您回答了你自己的問題,也許你可以寫一個答案並接受它?這將允許問題顯示爲「已回答」。 –

回答