Anatoly Rozhkov
Anatoly Rozhkov

Reputation: 67

Run every pytest test function simultaneously with another function

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

Upvotes: 0

Views: 520

Answers (1)

Teejay Bruno
Teejay Bruno

Reputation: 2159

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()

Upvotes: 1

Related Questions