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.
@pytest.fixture(scope='function', autouse=True)
def test_blackbox(request):
session = request.node
html = request.config._html
report_content = html._generate_report(session)
html._save_report(report_content)
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.
解决方案
推荐阅读
- c# - EF Core OrderBy 其他表上的引用计数
- javascript - html代码而不是来自dom的对象,带有监听器点击功能
- ios - 来自某些用户的 EXC_BAD_ACCESS KERN_INVALID_ADDRESS
- sql - SQL - 从不同 ID 的同一列添加值
- python - functools.partial 的正确类型提示
- android - 我应该对分组提醒使用本地通知还是远程通知?
- sql - Mariadb 错误:您的 SQL 语法有错误;检查与您的 MariaDB 服务器版本相对应的手册,以了解在附近使用的正确语法
- android-studio - Android Studio 中的库依赖
- postgresql - 在构建期间从 podman 容器访问本地 postgres 数据库
- spring - Websocket CORS 配置 Spring boot