import pytest

@pytest.fixture(scope="session")
def initdir(tmpdir):
    tmpdir.chdir()

import pytest

@pytest.fixture(autouse=True)
def initdir(tmpdir):
    tmpdir.chdir()

Switch from scope="session" to autouse=True
Switch from scope="session" to autouse=True
