The easiest way to use a fixture is to name it.

We can put the fixture name in the parameter list for each test that needs it:

import pytest

@pytest.fixture()
def before():
    print('\nbefore each test')

def test_1(before):
    print('test_1()')

def test_2(before):
    print('test_2()')

The fixture is going to be called for every test that names the fixture in it’s parameter list.

Output:

$ pytest -s test_fixture.py 
=========== test session starts ============
collected 2 items                          

test_fixture.py 
before each test
test_1()
.
before each test
test_2()
.

============ 2 passed in 0.05s =============