Skip to content

Instantly share code, notes, and snippets.

@sneakyPad
Created March 15, 2025 20:22
Show Gist options
  • Select an option

  • Save sneakyPad/aec1fda06f6deab6d0c2a72935760af5 to your computer and use it in GitHub Desktop.

Select an option

Save sneakyPad/aec1fda06f6deab6d0c2a72935760af5 to your computer and use it in GitHub Desktop.
# Originally taken from: https://docs.pytest.org/en/stable/explanation/fixtures.html#fixture-errors
import pytest
@pytest.fixture
def order():
return []
@pytest.fixture
def append_first(order):
raise Exception
order.append(1)
@pytest.fixture
def append_second(order, append_first):
order.extend([2])
@pytest.fixture(autouse=True)
def append_third(order, append_second):
order += [3]
def test_order(order):
assert order == [1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment