Linux pytest +allure 运行遇到的坑

1.Python3 run.py  无法运行pytest框架

服务器安装:

 pip install pytest。我也能用Python导入库 

解决方法:

python -m pytest 

python3 -m pytest  --html=%s/report.html --self-contained-html  --alluredir %s 

2.allure运行报错 “ValueError: option names {'--alluredir'} already added”

问题排查:

依赖包冲突 

pytest-allure-adaptor与allure-pytest的alluredir都被引用造成冲突

解决办法: 

需要卸载不用的包 :pip uninstall pytest-allure-adaptor

3.脚本执行完成后 不生成allure 报告

问题排查:

通过打印运行时系统PATH变量,发现Python在运行的时候 没有加载系统环境变量

解决办法:

代码内手动增加环境变量写入,使运行的时候自动添加运行环境变量

path = "/usr/bin:/usr/local/sbin:/usr/sbin:/home/jenkinsx/.local/bin:/home/jenkinsx/bin:/home/jenkinsx/workspace/allure-2.13.8/bin"
        shell.invoke(cmd, env={"PATH": path})


class Shell:
    @staticmethod
    def invoke(cmd, env={}):
        output, errors = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env).communicate()
        o = output.decode("utf-8")
        return o

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值