python - Pytest setup/teardown hooks for session -
pytest
has setup , teardowns
hooks module, class, method
.
i want create custom test environment in setup (before start of test session) , cleanup after tests finished. in other words, how can use hooks setup_session , teardown_session
?
these hooks work me:
def pytest_sessionstart(session): # setup_stuff def pytest_sessionfinish(session, exitstatus): # teardown_stuff
but next fixture session scope looks prettier:
@fixture(autouse=true, scope='session') def my_fixture(): # setup_stuff yield # teardown_stuff
Comments
Post a Comment