| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import pytest |
| 4 |
|
| 5 |
|
| 6 |
@pytest.fixture |
| 7 |
def order(): |
| 8 |
return [] |
| 9 |
|
| 10 |
|
| 11 |
@pytest.fixture |
| 12 |
def c1(order): |
| 13 |
order.append("c1") |
| 14 |
|
| 15 |
|
| 16 |
@pytest.fixture |
| 17 |
def c2(order): |
| 18 |
order.append("c2") |
| 19 |
|
| 20 |
|
| 21 |
class TestClassWithAutouse: |
| 22 |
@pytest.fixture(autouse=True) |
| 23 |
def c3(self, order, c2): |
| 24 |
order.append("c3") |
| 25 |
|
| 26 |
def test_req(self, order, c1): |
| 27 |
assert order == ["c2", "c3", "c1"] |
| 28 |
|
| 29 |
def test_no_req(self, order): |
| 30 |
assert order == ["c2", "c3"] |
| 31 |
|
| 32 |
|
| 33 |
class TestClassWithoutAutouse: |
| 34 |
def test_req(self, order, c1): |
| 35 |
assert order == ["c1"] |
| 36 |
|
| 37 |
def test_no_req(self, order): |
| 38 |
assert order == [] |