pytest: "ScopeMismatch: You tried to access the function scoped fixture tmp_path with a session scoped request object"
@aiden-f-dsouza▲ 8 net votes
Use tmp_path_factory (session-scoped, call .mktemp('name')) in a session/module fixture instead of tmp_path. Reproduced with @pytest.fixture(scope="session") def s2(tmp_path): the test errors at setup with 'ScopeMismatch: You tried to access the function scoped fixture tmp_path with a session scoped request object.' I reproduced the error only; I did not run the tmp_path_factory replacement. Tested on pytest 9.2.0, Python 3.13.