{"id":7619,"library":"pytest-pythonpath","title":"Pytest Pythonpath Plugin","description":"pytest-pythonpath is a pytest plugin designed to extend the `PYTHONPATH` from `pytest.ini` configuration files or command-line arguments before tests run. It provides functionality to add arbitrary directories to `sys.path` for module discovery during test execution. This plugin reached version 0.7.4 in February 2022 and is now largely considered obsolete since `pytest` version 7.0.0 introduced equivalent built-in functionality.","status":"maintenance","version":"0.7.4","language":"en","source_language":"en","source_url":"https://github.com/bigsassy/pytest-pythonpath","tags":["pytest","testing","pythonpath","module-resolution","plugin"],"install":[{"cmd":"pip install pytest-pythonpath","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core testing framework it extends.","package":"pytest","optional":false}],"imports":[],"quickstart":{"code":"[pytest]\npython_paths = src my_project/libs\nsite_dirs = other_packages","lang":"ini","description":"To configure `pytest-pythonpath`, create or modify your `pytest.ini` file. The `python_paths` option adds directories to the beginning of `sys.path`. The `site_dirs` option processes directories similar to `.pth` files, using `addsitedir`, though these paths might not be at the very front of `sys.path`. Paths are relative to the project's root directory."},"warnings":[{"fix":"Remove `pytest-pythonpath` from your dependencies (`pip uninstall pytest-pythonpath`). Use the built-in `pytest` configuration in your `pytest.ini`, `pyproject.toml`, or `setup.cfg` (e.g., `[pytest] pythonpath = src`).","message":"The `pytest-pythonpath` plugin is largely obsolete and not recommended for use with `pytest` versions 7.0.0 and later. `pytest` itself now includes a built-in `pythonpath` configuration option that provides the same core functionality, potentially leading to conflicts or ignored configurations if both are used.","severity":"breaking","affected_versions":">=7.0.0 of pytest"},{"fix":"Prefer `python_paths` if you need your specified directories to be at the absolute front of `sys.path` to ensure your local modules are found before others. Use `site_dirs` only when `addsitedir` behavior (e.g., `.pth` file processing) is specifically desired.","message":"Using `site_dirs` in `pytest.ini` for `pytest-pythonpath` (or its built-in equivalent) processes directories differently than `python_paths`. `site_dirs` uses `site.addsitedir`, which might not place the paths at the very beginning of `sys.path`, potentially causing module resolution order issues if you expect strict precedence.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure your `pytest.ini` includes the path to your module's root directory under `[pytest] pythonpath = your/module/root`. With `pytest >= 7.0.0`, ensure you're using `pytest`'s built-in `pythonpath` option and not relying on the `pytest-pythonpath` plugin.","cause":"Pytest cannot find your application's modules because their containing directories are not on the `PYTHONPATH` during test execution.","error":"ModuleNotFoundError: No module named 'your_module'"},{"fix":"Uninstall `pytest-pythonpath` and configure your `pythonpath` directly in `pytest.ini` or `pyproject.toml` using `pytest`'s native `pythonpath` option. For example, `[pytest] pythonpath = .` or `[tool.pytest.ini_options] pythonpath = [\"src\"]`.","cause":"This specific error message indicates a conflict where `pytest` 7.0.0+ has its own `pythonpath` handling, overriding or clashing with the `pytest-pythonpath` plugin's configuration.","error":"Pytest 7.0.0 appears to break pytest-pythonpath python_paths in pytest.ini"}]}