首页 > 解决方案 > Pytest Html 报告不可用

问题描述

我正在尝试为我的 pytest 生成 html 报告。我看到非常奇怪的行为。首先我在 raspbian 上运行,使用 python 3.7。

我正在运行两个命令

pytest --html=report.html DeviceTests/DisioOnUsb.py --device_id 9101 --firmware_version 0.1.1

sudo pytest --html=report.html DeviceTests/DisioOnUsb.py --device_id 9101 --firmware_version 0.1.1

现在我需要使用 sudo 因为我没有提升这个用户的权限。如果我运行第一个命令 pytest 运行良好,创建 html 但失败,因为后面的一些操作需要提升的用户权限。第二个命令失败并告诉我

ERROR: usage: pytest [options] [file_or_dir] [file_or_dir] [...]
pytest: error: unrecognized arguments: --html=report.html
  inifile: None
  rootdir: /home/pi/Documents/Disio Production Test

当我列出我的插件时,一切似乎都井井有条。sudo 在做什么?为什么我不能使用 sudo 创建此报告?

pi@raspberrypi:~/Documents/Disio Production Test $ pip3 freeze | grep pytest
pytest==6.2.5
pytest-html==3.1.1
pytest-metadata==1.11.0

标签: python-3.xpytest

解决方案


为了解决我的问题,我执行了操作

sudo pip3 uninstall pytest-html

其次是

sudo pip3 install pytest-html

推荐阅读