1、打开Python文件所在位置,我的路径为 D:\Python\Lib\site-packages\pytest_html,找到result.py文件,做出如下修改 2、 还有一种修改方式,打开 D:\Python\Lib\site-packages\pytest_html,找到plugin.py做出同上述一样的修改 3、经过上述修改后,中文乱码问题依旧没有解决 经过多方查找,又找到如下修改方式,把html_r...
pytest.main(["test.py::Test", # "运行文件名"::"类名"::"方法名" "--alluredir", # 创建allure报告的路径 "../report/allure/temp_jsonreport", # allure生成的报告是json格式的,需要再转化成html格式的,所以会自动生成一个temp_jsonreport文件 "--clean-alluredir", # 先清空再生成新的测试报告 ...
用pytest框架,生成的html报告中,中文显示乱码,如下图: 找到pytest-html 插件下的plugin.py(路径:/lib/python3.9/site-packages/pytest_html/plugin.py)做如下修改: python 将self.test_id = report.nodeid.encode("utf-8").decode("unicode_escape") 改为:self.test_id = report.nodeid 中文显示乱码的...
保存文件并重新运行pytest命令,查看是否解决了中文乱码问题。如果以上方法都无法解决问题,可能是由于其他原因导致的中文乱码问题。此时,可以尝试更新pytest和pytest_html插件到最新版本,或者检查其他相关环境配置是否正确。另外,确保在编写测试用例时使用的编码方式与报告中使用的编码方式一致,也可以避免中文乱码问题的出现。总...
pytest.main(['-vs']) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 生成报告执行命令: pytest --html=report.html 打开报告,呈现出这样的HTML。看起来和unittest的报告其实差不多的。 执行报告路径 如果在PO模式下通常都会把报告内容放到对应的report目录下,生成路径时候,我们也可以...
用pytest框架,生成的html报告中,中文显示乱码,如下图: 找到pytest-html 插件下的plugin.py(路径:/lib/python3.9/site-packages/pytest_html/plugin.py)做如下修改: 将self.test_id=report.nodeid.encode("utf-8").decode("unicode_escape") 改为:self.test_id=report.nodeid ...