Created
March 15, 2025 20:22
-
-
Save sneakyPad/aec1fda06f6deab6d0c2a72935760af5 to your computer and use it in GitHub Desktop.
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
| # 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