pytest-runner
pytest-runner is a setuptools extension that historically allowed pytest to be invoked via `python setup.py test`. Version 6.0.1 is the latest release, but the project is officially deprecated and its GitHub repository was archived in December 2023. It is no longer recommended for use in modern Python projects due to reliance on deprecated setuptools features and security concerns.
Warnings
- breaking The `pytest-runner` project is officially deprecated and its GitHub repository was archived in December 2023. The `setup.py test` command it enables is also being deprecated and slated for removal by `setuptools` itself. You should migrate away from `pytest-runner` for all projects.
- gotcha `pytest-runner` (and the `setup_requires`/`tests_require` mechanism it relies upon) can bypass security mechanisms in `pip`, specifically `pip --require-hashes`. This can lead to insecure dependency resolution.
- gotcha For new projects, or migrating existing ones, `pytest-runner` is unnecessary. `pytest` should be installed as a regular development dependency, typically specified in `pyproject.toml` (`[project.optional-dependencies]`) or `requirements-dev.txt`, and invoked directly from the command line (e.g., `pytest` or `python -m pytest`).
Install
-
pip install pytest-runner
Quickstart
# In setup.py (NOTE: This usage pattern is deprecated!)
from setuptools import setup, find_packages
setup(
name='my-package',
version='0.1.0',
packages=find_packages(),
setup_requires=[
'pytest-runner',
],
tests_require=[
'pytest',
],
)
# To run tests (from your project root):
# python setup.py pytest
# OR python setup.py test (if 'test=pytest' alias is set in setup.cfg)