Skip to content

Instantly share code, notes, and snippets.

@tjkhara
Created October 18, 2020 16:32
Show Gist options
  • Select an option

  • Save tjkhara/0aee59e23c9c5cbf42599e3230484a0d to your computer and use it in GitHub Desktop.

Select an option

Save tjkhara/0aee59e23c9c5cbf42599e3230484a0d to your computer and use it in GitHub Desktop.
Two teardown options
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