用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill pytest-testing命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | pytest-testing |
| description | > Use when this capability is needed. |
| Pattern | Purpose |
|---|---|
tests/ directory | All test files go here |
test_*.py | Test file naming |
Test* | Test class naming |
test_* | Test function naming |
conftest.py | Shared fixtures |
FastAPI handlers are async def. Use AsyncClient with pytest-asyncio:
import pytest
from httpx import AsyncClient
from myapp.main import app
@pytest.mark.asyncio
async def test_create_candidate():
async with AsyncClient(app=app, base_url="http://test") as client:
response = await client.post(
"/candidates",
json={
"full_name": "John Doe",
"email": "john@example.com",
"skills": ["Python", "FastAPI"],
"years_of_experience": 5
}
)
assert response.status_code == 201
When testing endpoints that launch BackgroundTasks:
@pytest.mark.asyncio
async def test_evaluation_returns_202():
async with AsyncClient(app=app, base_url="http://test") as client:
response = await client.post(
"/evaluations",
json={"candidate_id": "...", "job_id": "..."}
)
# Returns 202 immediately
assert response.status_code == 202
# Check DB for completed status
evaluation_id = response.json()["id"]
# Poll or wait for status change
import pytest
from httpx import AsyncClient
from sqlmodel import Session, SQLModel, create_engine
from myapp.main import app
from myapp.db import get_session
# Test database engine
TEST_DATABASE_URL = "postgresql://user:pass@localhost/test_db"
@pytest.fixture
def test_engine():
engine = create_engine(TEST_DATABASE_URL)
SQLModel.metadata.create_all(engine)
yield engine
SQLModel.metadata.drop_all(engine)
@pytest.fixture
def session(test_engine):
with Session(test_engine) as session:
yield session
@pytest.fixture
async def client():
async with AsyncClient(app=app, base_url="http://test") as client:
yield client
from pydantic import ValidationError
from myapp.schemas.candidate import CandidateCreate
def test_candidate_create_valid():
candidate = CandidateCreate(
full_name="John Doe",
email="john@example.com",
skills=["Python"],
years_of_experience=5
)
assert candidate.email == "john@example.com"
def test_candidate_create_invalid_email():
with pytest.raises(ValidationError):
CandidateCreate(
full_name="John",
email="invalid-email",
skills=["Python"],
years_of_experience=5
)
from myapp.models.candidate import Candidate
def test_candidate_model_defaults():
candidate = Candidate(
full_name="John",
email="john@test.com",
skills=["Python"],
years_of_experience=3
)
assert candidate.id is not None
assert candidate.created_at is not None
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=myapp --cov-report=html
# Run specific test file
pytest tests/test_candidates.py
# Run specific test
pytest tests/test_candidates.py::test_create_candidate
# Run with verbose output
pytest tests/ -v
# Run with async mode auto (from pyproject.toml)
pytest tests/ -v
# Stop on first failure
pytest tests/ -x
# Show local variables in failures
pytest tests/ -l
tests/ directorytest_*.pypytest.mark.asyncio for async testsAsyncClient for endpoint testsSource: ColRuDev/job-candidate-matcher — distributed by TomeVault.