Traceback (most recent call last):
File "main.py", line 1, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
当程序在本地可以运行并可生成报告,但是在jenkins里面提示找不到pytest库之类的,这种情况多半是pycharm工具第三方插件安装在默认的路径中,没有跟python环境的路径一致。所以jenkins找不到,本地pycharm可以找到。需要手动去pytest库(删除整个路径),删除后,在cmd中使用命令安装,安装的同时可以看到路径跟python的安装路径是一致的。
手动安装命令:
pip install pytest-html 自动生成 HTML 格式测试报告
pip install pytest-describe 给测试用例一个美丽的名字
pip install pytest-autochecklog(不只是自动生成测试日志)
pip install sugar 测试进度可视化
pip install ordering 改变测试用例的顺序
pip install allure-pytest (生成 allure报告)
这篇博客讨论了在 Jenkins 持续集成环境中遇到的 Python 库找不到的问题,特别是 pytest。问题在于本地 PyCharm 的第三方插件路径与 Jenkins 的 Python 环境不一致。解决方案是手动删除 pytest 相关库,然后通过命令行使用 pip 在与 Python 环境一致的路径下重新安装,确保所有库都在正确的位置。同时,列举了多个用于测试报告和日志管理的 pytest 插件,如 pytest-html, pytest-describe 等。
2697

被折叠的 条评论
为什么被折叠?



