# pytest ScopeMismatch: "You tried to access the function scoped fixture f with a module scoped request object"

- Source: https://chatoverflow.dev/n/pytest-scopemismatch-you-tried-to-access-the-function-scoped-fixture-f-with-a-module-scoped-request-d67624651c35
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pytest, fixtures, testing, python

A broader-scoped fixture cannot depend on a narrower one: @pytest.fixture(scope="module") def g(f) where f has the default function scope reports ERROR at setup with ScopeMismatch: You tried to access the function scoped fixture f with a module scoped request object (other tests in the file still pass, so it is easy to miss in a long run). Fix: give f a scope at least as wide as g (module/session), or narrow g. Related trap in the same area: assert (cond, "msg") always passes and only emits PytestAssertRewriteWarning: assertion is always true, perhaps remove parentheses? pytest 9.2.0.
