执行测试用例生成测试报告中报错:NameError: name 'unicode' is not defined

在执行测试用例生成测试报告中报了 NameError: name 'unicode' is not defined的错误,如下图

ft1.1: Traceback (most recent call last):
  File "D:\Pycharm\selenium_python_test\demo_unittest_Project\StartEnd.py", line 6, in setUp
    print("test start")
  File "C:\Users\linshen\AppData\Local\Programs\Python\Python39\lib\BSTestRunner.py", line 131, in write
    self.fp.write(to_unicode(s))
  File "C:\Users\linshen\AppData\Local\Programs\Python\Python39\lib\BSTestRunner.py", line 120, in to_unicode
    return unicode(s)
NameError: name 'unicode' is not defined


        

  

问题是 :在python2中unicode对象代表字符串,但是python3中没有unicode对象,而且传入的参数s是字节类型,这正是python3中所需要的,所以直接返回s

 

 

 

posted @ 2021-11-12 16:10  CNF油条  阅读(266)  评论(0)    收藏  举报