conftest.py文件里已经加了对应的代码
yaml文件写的是中文
但是测试用例运行之后显示的就是乱码
代码地址:https://github.com/zengxuejie0710/New_2020-0710/tree/master/hogwarts/manfunc
conftest.py文件里已经加了对应的代码
但是测试用例运行之后显示的就是乱码
代码地址:https://github.com/zengxuejie0710/New_2020-0710/tree/master/hogwarts/manfunc
在open方法里加一个参数encoding='utf-8'
试试看
请问 在open方法里加一个参数`encoding=‘utf-8’,但是控制台显示的unicode编码:test_calc.py::TestCalc::test_add[\u96f6\u548c\u6b63\u6574\u6570\u76f8\u52a0]
请问要怎么解决?
这个在讲pytest章节的时候就会讲到了,使用pytest提供的hook函数对用例名称进行一次转码就可以了
def pytest_collection_modifyitems(session: "Session", config: "Config", items: List["Item"]) -> None:
for item in items:
item.name = item.name.encode("utf-8").decode("unicode-escape")
item._nodeid = item._nodeid.encode("utf-8").decode("unicode-escape")