-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Are there hooks for module setup/teardown? #3677
Comments
GitMate.io thinks possibly related issues are #265 (teardown method called even for skipped tests (and setup isn't)), #2205 (optimize io capture setup/teardown), #91 (Package-level setup and teardown), #2718 (Please consider adding context manager versions of setup/teardown), and #377 (nose's .setUp() and .tearDown() are not supported). |
Hi @yoyoyopcp, The short answer is no, the closest I can think of are the pytest_fixture_setup and pytest_fixture_post_finalizer hooks when they are used for module-scoped fixtures. |
This might be helpful: import pytest
@pytest.fixture(autouse=True, scope='module')
def module_setup_teardown():
print("MODULE SETUP!!!")
yield
print("MODULE TEARDOWN!!!")
def test1():
print("TEST1!!!")
def test2():
print("TEST2!!!") $ pytest -s test.py
============================== test session starts ===============================
platform darwin -- Python 3.7.0, pytest-3.6.3, py-1.5.4, pluggy-0.6.0
rootdir: /private/tmp/t, inifile:
collected 2 items
test.py MODULE SETUP!!!
TEST1!!!
.TEST2!!!
.MODULE TEARDOWN!!!
============================ 2 passed in 0.01 seconds ============================ |
oh but for plugin hooks, 🤔 |
Plugins can just make a internal fixtures |
There are many hooks around setting up/tearing down functions and there are hooks for session start/finish, but are there any for modules?
The text was updated successfully, but these errors were encountered: