与另一个功能同时运行每个pytest测试功能

发布于 2025-02-05 01:39:04 字数 254 浏览 3 评论 0原文

我希望每个pytest测试与功能录制视频同时运行。我想以某种方式让Pytest做类似

Test_function 的事情1 test_function2 test_function

pytest调用每个函数以进行执行时,它将将其与rection_video()相结合。就像test_function {n} + record_video()

最终,它返回了有关如何执行测试的报告以及带有录音的.mp4文件。

如何实现?我想应该以某种方式

I want every pytest test run simultaneously with a function recording video. I want to somehow make pytest do something like this

test_function1
test_function2
test_function

When pytest would call every function for execution it would couple it with record_video(). Like test_function{n} + record_video()

In the end it woud return a report on how the test was executed and a .mp4 file with a recording.

How to achieve that? I guess it should be possible somehow

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

疾风者 2025-02-12 01:39:05

fixtures 是对此的完美用例。

请参见以下假设示例 -

import pytest


@pytest.fixture
def record_video():
    record.start()
    yield
    record.stop()


@pytest.fixture(scope="session")
def generate_report():
    yield
    report.make()

Fixtures are a perfect use case for this.

See the following hypothetical example --

import pytest


@pytest.fixture
def record_video():
    record.start()
    yield
    record.stop()


@pytest.fixture(scope="session")
def generate_report():
    yield
    report.make()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文