Fedor March
Fedor March

Reputation: 87

How do I run the test after completing all the tests? (

There are several tests in the tests folder: test_first.py , test_second.py . Each test checks the operation of the site by creating and modifying projects. I need that, regardless of how I run the tests tests/test_first.py or tests/ upon completion of all tests, the delete_prj function is executed, which deletes the created project after the tests have run. I'm not asking for the task execution code, the answer to the question is enough

Upvotes: 0

Views: 83

Answers (1)

Sören
Sören

Reputation: 2454

Use a session scoped fixture. Something like this:

import pytest

@pytest.fixture(autouse=True, scope="session")
def do_stuff_after_everything_is_done():
    yield
    delete_prj()

(untested)

Upvotes: 2

Related Questions