问题:RobotFramework在win10跑用例过程中有中文日志会显示非中文,如截图:

解决:

 C:\Python27\Lib\site-packages\robot\utils\unic.py ,用该文件内容替换:
  1. # Copyright 2008-2015 Nokia Networks
  2. # Copyright 2016- Robot Framework Foundation
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15.  
  16. from pprint import PrettyPrinter
  17.  
  18. from .platform import IRONPYTHON, JYTHON, PY2
  19. from .robottypes import is_bytes, is_unicode
  20. import json
  21.  
  22. if PY2:
  23.  
  24. def unic(item):
  25. if isinstance(item, unicode):
  26. return item
  27. if isinstance(item, (bytes, bytearray)):
  28. try:
  29. return item.decode('ASCII')
  30. except UnicodeError:
  31. return u''.join(chr(b) if b < 128 else '\\x%x' % b
  32. for b in bytearray(item))
  33. if isinstance(item,(list,dict,tuple)):
  34. try:
  35. item = json.dumps(item,ensure_ascii=False,encoding='cp936')
  36. except UnicodeDecodeError:
  37. try:
  38. item = json.dumps(item,ensure_ascii=False,encoding='cp936')
  39. except:
  40. pass
  41. except:
  42. pass
  43. try:
  44. try:
  45. return unicode(item)
  46. except UnicodeError:
  47. return unic(str(item))
  48. except:
  49. return _unrepresentable_object(item)
  50.  
  51. else:
  52.  
  53. def unic(item):
  54. if isinstance(item, str):
  55. return item
  56. if isinstance(item, (bytes, bytearray)):
  57. try:
  58. return item.decode('ASCII')
  59. except UnicodeError:
  60. return ''.join(chr(b) if b < 128 else '\\x%x' % b
  61. for b in item)
  62. try:
  63. return str(item)
  64. except:
  65. return _unrepresentable_object(item)
  66.  
  67. # JVM and .NET seem to handle Unicode normalization automatically. Importing
  68. # unicodedata on Jython also takes some time so it's better to avoid it.
  69. if not (JYTHON or IRONPYTHON):
  70.  
  71. from unicodedata import normalize
  72. _unic = unic
  73.  
  74. def unic(item):
  75. return normalize('NFC', _unic(item))
  76.  
  77. def prepr(item, width=400):
  78. return unic(PrettyRepr(width=width).pformat(item))
  79.  
  80. class PrettyRepr(PrettyPrinter):
  81.  
  82. def format(self, object, context, maxlevels, level):
  83. try:
  84. if is_unicode(object):
  85. return repr(object).lstrip('u'), True, False
  86. if is_bytes(object):
  87. return 'b' + repr(object).lstrip('b'), True, False
  88. return PrettyPrinter.format(self, object, context, maxlevels, level)
  89. except:
  90. return _unrepresentable_object(object), True, False
  91.  
  92. def _unrepresentable_object(item):
  93. from .error import get_error_message
  94. return u"<Unrepresentable object %s. Error: %s>" \
  95. % (item.__class__.__name__, get_error_message())

RF:win10跑用例过程中有中文日志会显示非中文的更多相关文章

  1. JDK13.0.1安装与环境变量的配置(Win10平台为例)

    一.下载与安装 Oracle官网下载:https://www.oracle.com/technetwork/java/javase/downloads/index.html,点击右侧下载 接受并下载对 ...

  2. WiFi无线连接过程中有哪几个主要步骤?

    WiFi无线连接过程中有哪几个主要步骤?[1]在使用WIFI功能时,经常性的操作是打开手机上的WiFi设备,搜索到心目中的热点,输入密码,联网成功,成功上网.这个看似简单的过程,背后却是隐藏着大量的无 ...

  3. python matplotlib plot 数据中的中文无法正常显示的解决办法

    转发自:http://blog.csdn.net/laoyaotask/article/details/22117745?utm_source=tuicool python matplotlib pl ...

  4. 【原创】python中文编码问题深入分析(二):print打印中文异常及显示乱码问题分析与解决

    在学习python以及在使用python进行项目开发的过程中,经常会使用print语句打印一些调试信息,这些调试信息中往往会包含中文,如果你使用python版本是python2.7,或许你也会遇到和我 ...

  5. Android实现中文汉字笔划(笔画)、中文拼音排序、英文排序

    发布时间:2018-11-16   技术:Android   概述 最近要做一个类似微信的,在登录界面选择国家地区的功能,微信有中文汉字笔画排序以及中文拼音排序等几种方式,如下所示: 简体中文 拼音排 ...

  6. ELKF-分布式日志收集分析平台搭建 最小化 配置过程 - 查看收集日志(windows10下搭建)

    前言 Elasticsearch是与名为Logstash的数据收集和日志解析引擎以及名为Kibana的分析和可视化平台一起开发的.这三个产品被设计成一个集成解决方案,称为“Elastic Stack” ...

  7. C语言重定向输入:txt文件内容是中文,重定向输入显示乱码的原因

    一.txt文件中的内容是中文,重定向输入显示乱码原因: 是因为文本文件的编码和和编译器的不一致导致的.我文本文件用的编码是UTF-8,而编译器是ANSI,不匹配,所以输出乱码.文本另存为时把编码改为A ...

  8. Windows server 2012 添加中文语言包(英文转为中文)(离线)

    Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...

  9. JFreechart在linux下不显示及中文乱码问题

    一.使用JFreeChart建的报表,在window下能正常显示,但是放到linux下就报错,而且有时候会把tomcat挂掉, 原因是jfreechart的在linux系统中需要访问java awt库 ...

随机推荐

  1. python学习笔记(1)python中的注释和安装python

    注释 目标 注释的作用 单行注释 多行注释 01注释的作用 在程序中对代码的标注说明,增强代码的可读性 以 # 开头,# 右边的所有东西都被当做说明文字,而不是真正要执行的程序,只起到辅助说明作用 为 ...

  2. java自定义注释

    一.什么是注释 说起注释,得先提一提什么是元数据(metadata).所谓元数据就是数据的数据.也就是说,元数据是描述数据的.就象数据表中的字段一样,每个字段描述了这个字段下的数据的含义.而J2SE5 ...

  3. 【学习】C++多态机制

    多态:静态(早绑定) 在编译阶段和链接就能确定功能调用的函数.     动态(晚绑定) 在程序运行时根据需要的功能确定调用的函数. 实现晚绑定就要定义虚函数,使用虚函数则会用到基类指针. 继承基类虚成 ...

  4. JS写法 数值与字符串的相互转换 取字符中的一部分显示 正则表达规则

    http://www.imooc.com/article/15885 正则表达规则 <script type="text/javascript"> </scrip ...

  5. Java I/O输入输出流

    IO流的复习总结 ------注:蓝色背景段落是例子:红色背景的字段IO流的功能类. 编码问题 String s = "威力锅ABC";  //utf-8编码中文占用三个字节,英文 ...

  6. explain和profiling分析查询SQL时间

    mysql可以通过profiling命令查看到执行查询SQL消耗的时间. 默认情况下,mysql是关闭profiling的,命令: select @@profiling; +------------- ...

  7. 对css语法中position值的理解

    1.static 正常定位,就是默认定位,根据他的top,right,bottom,left的值 2.relative 根据他top,right,bottom,left的值偏移 3.absolute ...

  8. remove-weknow-ac from mac chrome

    refer:https://macreports.com/how-to-remove-weknow-ac-malware-macos/ 1-Remove the weknow.ac profile. ...

  9. Linux下的常用文本编辑器

    Linux的文本编辑器 ed 在早期的unix平台上,ed可以说是唯一的编辑工具.它是一个很古老的行编辑器,vi这些编辑器都是从ed 演化而来.行编辑器使用起来很不方便,每次只能对一行进行操作,.而后 ...

  10. Spring Boot 全局异常处理

    Spring Boot版本 1.5 @ControllerAdvice public class GlobalExceptionHandler extends ResponseEntityExcept ...