Created
October 18, 2020 16:32
-
-
Save tjkhara/0aee59e23c9c5cbf42599e3230484a0d to your computer and use it in GitHub Desktop.
Two teardown options
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pytest | |
| @pytest.fixture() | |
| def setup1(): | |
| print("\nSetup 1") | |
| yield | |
| print("\nTeardown 1") | |
| @pytest.fixture() | |
| def setup2(request): | |
| print("\nSetup 2") | |
| def teardown_a(): | |
| print("\n Teardown A") | |
| def teardown_b(): | |
| print("\n Teardown B") | |
| request.addfinalizer(teardown_a) | |
| request.addfinalizer(teardown_b) | |
| def test1(setup1): | |
| print("\nExecuting test 1") | |
| assert True | |
| def test2(setup2): | |
| print("\nExecuting test 2") | |
| assert True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment