AgentSkillsCN

pytest-runner

在运行 pytest 测试时,自动激活虚拟环境。每当需要运行测试、执行 pytest,或被要求“运行测试”、“测试这个”,或执行任何测试任务时,都可使用此技能。确保在 pytest 运行前始终激活 venv。

SKILL.md
--- frontmatter
name: pytest-runner
description: Run pytest tests with automatic virtual environment activation. Use this skill whenever running tests, executing pytest, or when asked to "run tests", "test this", or any test execution task. Ensures venv is always activated before pytest runs.

Pytest Runner

Always activate the virtualenv before running pytest. Look for .venv in the project directory:

bash
source .venv/bin/activate && pytest <test-path> --reuse-db -n <N>

Test Selection

Always specify which tests to run. Never run the entire suite without reason.

Run most-likely-to-fail first:

  1. New/changed test file specifically
  2. Entire module the changes belong to
  3. Entire project (only if needed)

--reuse-db

Always pass --reuse-db — unless you made model (database) changes beforehand, then omit it so the DB is recreated.

Concurrency (-n flag)

  • 1 test: -n0
  • 2-7 tests: -n matching count (e.g. 3 tests → -n 3)
  • 8+ tests: omit -n entirely