Fixture¶
data path fixture¶
import pytest
from pathlib import Path
DATA_PATH = Path(__file__).absolute().parent.joinpath('data')
@pytest.fixture
def data_path():
return DATA_PATH
def test_data_path(data_path: Path):
...
call fixture function directly¶
solution: https://github.com/pytest-dev/pytest/issues/3950
bad - default argument: this makes the fixture run at import time, not at test runtime
extract fixture
manual wrapping
direct invocation:
@pytest.fixturekeeps the original function in.__wrapped__