Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tomevault-io/skills-registry --skill pytest-testing명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
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.