fixture

A named piece of setup, defined with @pytest.fixture, that a test receives by listing the fixture's name as a parameter.

In more detail

pytest sees the parameter, builds the fixture, passes in its value and can tear it down afterwards. Setup that no test asks for never runs. Fixtures can use other fixtures, and their scope decides how often they are rebuilt.

Examples

bash make-fixture-repo.sh fixture  # a pinned history, so your metrics match the lesson
bash make-fixture-repo.sh fixture
@pytest.fixture
def basket():
    return [(250, 2), (125, 4)]

Related terms

Taught in

References