问题标签 [pytest-html]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - 如何在 pytest-html 报告中删除环境表
我正在尝试删除 pytest-html 报告中存在的环境表,但我不知道该怎么做?
我已附上 pytest-html 报告 在此处输入图像描述
python - 如何为 pytest 创建 HTML 报告?
我使用 pytest 框架在 Eclipse 中创建了一个项目
现在,我想为我的项目创建一个 html 报告。我做了以下工作:
- 安装了html插件
- 在 conftest.py 模块中编写以下代码
当我运行测试时,我没有得到任何报告。以下是我的预期结果,但没有生成报告
请指导我,因为我是 pytest 的新手
pytest - 如何使用 pytest-html 在 HTML 中嵌入 base64 图像?
我正在使用 python-appium 客户端并在测试完成后生成 HTML 报告。我想在 HTML 报告中添加失败测试的嵌入图像。嵌入图像的原因是我也可以从远程机器访问它。这是我尝试过的代码,在另一个系统上不起作用,但在本地它可以工作:
在我看来,编码图像没有正确生成,因为这是我在输出 HTML 文件中可以看到的:
我希望“src”不以“.png”结尾,它应该是一长串字符。我不知道如何解决这个问题。
python - 找不到满足 py.xml 要求的版本(来自版本:)找不到 py.xml 的匹配分发
我想使用以下代码修改 pytest 报告的结果表的列:
要使用上面的代码,我正在尝试安装 py.xml。在使用pip install py.xml
. ,我收到以下错误消息:
找不到满足 py.xml 要求的版本(来自版本:)找不到 py.xml 的匹配分发
请让我知道如何解决此问题
python - 如何参数化 pytest 的函数,以便从文本文件中获取参数和测试名称
如何对 pytest 的函数进行参数化,以便从文本文件中获取参数,并在每次迭代时更改函数名称以获取 pytest-html 报告
文本文件格式:Function_name | 断言值 | 从 postgresql 查询断言。
要求:创建一个基于pytest的框架
到目前为止,我的逻辑(它不起作用):
任何人都可以解释如何在每次迭代中更改函数名称,同时在 pytest fun 中传递参数
python-3.x - 如何使 pytest-html 单个 html 报告结果文件的所有行默认为折叠状态?
我使用 pytest 运行程序从我的自动化测试框架(Selenium 和 RestAPI 测试)中获取结果输出。我使用 pytest-html 插件在测试结束时生成单页 html 结果文件。我使用以下命令(从活动的 VirtEnv 会话)启动测试运行。
python -m pytest -v --html="api_name_test.html" --self-contained-html
(它有点复杂,因为我使用 powershell 脚本来运行它并提供带有日期时间戳的结果文件名并在完成时通过电子邮件发送文件,但它本质上是上面的命令)
当生成报告并打开此报告 html 时,我发现所有未通过的测试都已扩展。我想让它默认折叠所有行(失败、XFailed、错误等)。
我的项目在目录根目录中包含一个 conftest.py 文件和一个 pytest.ini 文件,我在其中指定测试脚本的目录
在我最简单的项目中的 conftest.py 文件中,我有一个可选的钩子来获取测试的目标 url 并将其放入报告摘要中:
Github 页面提到显示查询可用于折叠具有各种结果的行,但没有提及此信息的输入位置。 https://github.com/pytest-dev/pytest-html
“默认情况下,结果表中的所有行都将展开,除了那些已通过的行。可以使用查询参数自定义此行为:?collapsed=Passed,XFailed,Skipped”
目前我不确定该?collapsed=...
行是否进入命令行,或者 conftest 作为钩子,或者我是否需要编辑 pytest-html 插件附带的默认 style.css 或 main.js?(另外我不熟悉css,只知道少量的html)。我假设它作为钩子进入 conftest.py 文件,但并不真正了解如何应用它。
python - Pytest:测试运行后如何显示生成的报告?
我将 pytest 与pytest-html插件结合使用,该插件在测试运行后生成 HTML 报告。
我正在使用自动连接的会话夹具在浏览器中自动打开生成的 HTML 报告:
上面的代码有效,但不一致,因为有时浏览器会在文件创建之前尝试加载文件,这会导致文件未找到错误,并且需要手动刷新浏览器才能显示报告。
我的理解是这scope="session"
是最广泛的可用范围,我的假设是 pytest-html 应该在会话结束之前完成生成报告,但显然情况并非如此。
问题是:挂钩浏览器报告自动启动代码的正确方法是什么?难道这pytest-html
也与会话终结器范围挂钩?在这种情况下,如何确保 HTML 文件仅在文件创建后才在浏览器中打开?
python - Is it possible to generate a pytest HTML report on a timeout?
I'm using pytest
and want to combine two plugins in a graceful way, pytest-html
and pytest-timeout
. I'm operating on Windows, so I have to use the thread-method of timing out from pytest-timeout
, which causes a full-stop to all testing. I want an html from pytest-html
to be generated in this instance, but was unsure of the plausibility of this from hierarchy issues with the interrupt.
UPDATE, progress so far:
I've added a function to conftest.py
that manually generates the html before every test case, with the session data that exists at that point. This is a roundabout method of generating the html before the timeout, as opposed to only at the end of testing, simply because the html is being continuously regenerated throughout the process.
I could add similar code to the timeout_timer
method of timeout
, which is the function that is called when the timer thread runs out, but I want to avoid directly editing the plugin itself. I'll answer once I complete my original task.