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.
pip install pytest-pythonpathNo compatibility data collected yet for this library.
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.
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`).
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.
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.
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"]`.