开源测试工具 robotframework 运行中断后或重复运行后,ride 不打印日志解决

Sorin · 2018年04月08日 · 1036 次阅读

robotframework 运行中断后或重复运行后,ride 中经常会出现控制台不显示日志信息,

一、编码不支持中文的原因

Traceback (most recent call last):  
  File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunnerplug  
in.py", line 367, in OnTimer  
    self.OnProcessEnded(None)  
  File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunnerplug  
in.py", line 334, in OnProcessEnded  
    self.get_current_profile())  
  File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"  
, line 250, in get_output_and_errors  
    stdout, stderr, returncode = self._process.get_output(), \  
  File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"  
, line 305, in get_output  
    return self._output_stream.pop()  
  File "C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"  
, line 400, in pop  
    return result.decode('UTF-8')  
  File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode  
    return codecs.utf_8_decode(input, errors, True)  
UnicodeDecodeError: 'utf8' codec can't decode byte 0xca in position 0: invalid c  
ontinuation byte  

解决方法:

修改"C:\Python27\lib\site-packages\robotide\contrib\testrunner\testrunner.py"文件 pop 方法中 “ return result.decode('UTF-8')” 的 “UTF-8” 改成 “gbk”,重启 ride 就可以了

def pop(self):  
    result = ""  
    for _ in xrange(self._queue.qsize()):  
        try:  
            result += self._queue.get_nowait()  
        except Empty:  
            pass  
    return result.decode('gbk')  

二、运行完 case 后,没结束 driver,在每个用例的回收项中执行结束 driver 操作

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册