What this thread does
fixture 'db' not found
A test asks for a fixture name that pytest cannot resolve from that test's location.
Do first: run python -m pytest --fixtures tests/test_example.py, replacing the path with the failing file; is the missing name provided by your suite or by a plugin? Match the spelling against the fixture list. Diagnostic output example.
Evidence: official examples establish fixture visibility; a 2023-12-22 user report records a discovery failure affected by invocation context. That report does not establish every IDE or plugin combination.
Not for: pytest local-package import failures; see pytest-cannot-import-our-local-package-from-the-tests-folder.
Diagnostic: fixture 'db' not found
As of November 2026, these branches target projects pinned to pytest 8.4.2. Reference date: 2026-11-08. The 8.4.2 changelog dates that release to 2025-09-03.
1. Your fixture function exists, but is invisible — pytest 8.4.2. Add @pytest.fixture above the function and put shared fixtures in a conftest.py beside the tests or in a common ancestor directory. A fixture in a sibling test module is not automatically shared; changing scope="session" changes lifetime, not visibility. Follow the fixture definition guide and directory lookup rules. Confirmation: the fixture list for the failing file contains the exact requested name, then the selected test reaches its assertions.
2. Fixtures live in a reusable helper module — pytest 8.4.2. Register the importable module in the top-level conftest.py, for example pytest_plugins = ("myapp.testsupport.myplugin",) with your real module path. This is pytest's documented plugin-loading mechanism. Confirmation: python -m pytest --trace-config tests/test_example.py lists the module, and --fixtures lists its fixture. Keep pytest_plugins out of nested conftest files.
3. A third-party plugin owns the name — pytest 8.4.2. Use python -m pytest --trace-config tests/test_example.py to obtain active plugin names. Ensure the project's declared plugin dependency is installed in this interpreter; remove an unintended -p no:NAME, or explicitly load the required plugin with -p NAME when autoload is deliberately disabled. Substitute its actual plugin name. The 8.4 plugin guide documents PYTEST_DISABLE_PLUGIN_AUTOLOAD and --disable-plugin-autoload. Confirmation: both the plugin and fixture appear, then the selected test proceeds past setup.
4. The argument is ordinary example data — pytest 8.4.2. Parametrize it rather than expecting pytest to call the test with arbitrary arguments: @pytest.mark.parametrize("db", ["example"]) supplies a string to a matching def test_example(db):. Use values and a parameter name meaningful to your test. Parametrization guide. Confirmation: python -m pytest -v tests/test_example.py displays a case for the provided value and executes its assertion.
Evidence and limits
sundar-ds's December 2023 report includes the actual missing-name output and a later resolution after correcting execution context. It supports comparing the IDE invocation with the command-line invocation; it does not make changing directories a universal repair. db is an example name, not a built-in database fixture. Fixture visibility, fixture lifetime and the external service the fixture creates are separate questions; a later connection failure needs its own diagnosis.
Not for: pytest local-package import failures; see pytest-cannot-import-our-local-package-from-the-tests-folder.
Started from a post by @sundar-ds, packaged by the editor. Original post