| name | pytest-test-runner |
| description | Use this skill when the user says "run tests", "pytest", "test failing", "make test", "run the test suite", or when test output shows failures. Triggers include: "make test", "pytest tests/", "test error", "test coverage", "test_api", "test-services". When in doubt, use this skill rather than skipping it.
|
| license | MIT |
| metadata | {"version":"1.0.0","author":"Repository Analyst","priority":"high","category":"testing"} |
Pytest Test Runner
Role
You are an expert in running and debugging pytest tests for this FastAPI/RAG project. Your job is to execute tests with proper environment setup, diagnose failures, and suggest targeted fixes.
Workflow
- Set Environment — Tests require mock environment variables:
EMBEDDING_MODEL_URL and EMBEDDING_MODEL_API_KEY.
- Run Tests — Execute
make test or specific test targets (e.g., make test-api).
- Analyze Failures — Parse the pytest output to identify:
- Async test issues (missing
pytest-asyncio)
- Import errors (missing dependencies)
- Database connection issues (requires running services)
- Assertion failures (logic bugs)
- Fix Issues — Apply targeted fixes:
- For import/module errors: check
pyproject.toml dependencies
- For async errors: ensure
@pytest.mark.asyncio decorators present
- For database errors: verify Docker services are running (
make docker-up)
- For logic failures: read the source file and fix the implementation
- Re-run — Execute the specific test command again to verify the fix.
- Report — Summarize test results and any remaining failures.
Project Test Commands
make test
make test-api
make test-services
make test-config
make test-schemas
make test-cov
make test-unit
make test ARGS="-v -k test_analyze"
Test Files Location
tests/conftest.py — Shared fixtures
tests/test_main.py — App startup/health tests
tests/test_analyze.py — /api/v1/analyze endpoint tests
tests/test_data.py — /api/v1/data/ endpoint tests
tests/test_retrieval.py — RetrievalService tests
tests/test_embedding.py — EmbeddingService tests
tests/test_config.py — Settings validation tests
tests/test_schemas.py — Pydantic schema tests
Constraints
- NEVER run tests without setting the required env vars (done automatically via Makefile).
- DO NOT modify
conftest.py unless explicitly requested — it contains shared fixtures.
- Anti-Loop: If the same test fails 3 times, STOP and ask the user for guidance.
- For database integration tests, ensure Docker services are running first.
Examples
User: "Run the API tests and fix any failures"
Assistant:
Thinking:
- Run
make test-api to see which tests fail.
- Analyze the failure output to identify the root cause.
- Read the relevant source file to understand the issue.
- Apply the fix.
- Re-run
make test-api to verify.
Uses the bash tool with command make test-api