Run Python tests with uv and ensure tests are updated when code changes. Use this skill whenever the user asks to run, update, or verify Python tests using the uv package manager. uv run pytest automatically handles dependencies and path management for projects with pyproject.toml.
This skill ensures tests are reviewed and updated after any code modification, using uv run pytest for consistent, reproducible test execution.
⚠️ FORBIDDEN ACTIONS:
python3 -m pytestpip install pytest or any direct pip/venv commandspytest command✅ REQUIRED ACTIONS:
uv run pytestcurl -LsSf https://astral.sh/uv/install.sh | sh)pyproject.toml for dependency managementIdentify impacted behavior
Update or add tests
Run relevant tests
CORRECT way:
uv run pytest tests/ -v
WRONG ways (DO NOT USE):
# ❌ WRONG - Do not use these:
pytest tests/ -v
python3 -m pytest tests/ -v
venv/bin/pytest tests/ -v
Or run only the impacted test module(s):
uv run pytest tests/<test_module_name> -v
Install uv first:
curl -LsSf https://astral.sh/uv/install.sh | sh
The project needs a pyproject.toml file for uv to manage dependencies. Create one:
uv init
uv add --dev pytest
Add pytest as a dev dependency:
uv add --dev pytest
This means pytest is not installed in the project dependencies:
uv add --dev pytest
Command:
uv run pytest -v
Command:
uv run pytest tests/test_models.py -v
Command:
uv run pytest tests/ -v --tb=short