我有多个功能文件,每个文件至少包含5个场景(测试用例)。使用给出以下命令的Behave运行所有功能
behave --junit 我得到了以下异常
Exception UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 22: ordinal not in range(128)
Traceback (most recent call last):
File "myLoc/behave", line 9, in <module>
load_entry_point('behave==1.2.5', 'console_scripts', 'behave')()
File "project/lib/python2.7/dist-packages/behave/__main__.py", line 109, in main
failed = runner.run()
File "project/lib/python2.7/dist-packages/behave/runner.py", line 672, in run
return self.run_with_paths()
File "project/lib/python2.7/dist-packages/behave/runner.py", line 693, in run_with_paths
return self.run_model()
File "project/lib/python2.7/dist-packages/behave/runner.py", line 483, in run_model
failed = feature.run(self)
File "project/lib/python2.7/dist-packages/behave/model.py", line 523, in run
failed = scenario.run(runner)
File "project/lib/python2.7/dist-packages/behave/model.py", line 882, in run
if not step.run(runner):
File "project/lib/python2.7/dist-packages/behave/model.py", line 1499, in run
output = runner.log_capture.getvalue()
File "project/lib/python2.7/dist-packages/behave/log_capture.py", line 99, in getvalue
return '\n'.join(self.formatter.format(r) for r in self.buffer)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 22: ordinal not in range(128)当此异常发生时,behave不会运行下一个方案(测试)
有人能帮我解决这个问题吗?
发布于 2015-06-13 00:13:00
下面的代码对我很有效
import sys
reload(sys)
sys.setdefaultencoding('utf-8')https://stackoverflow.com/questions/30627013
复制相似问题