Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

pytest

БесплатноБез исполняемых скриптовНе проверен

Advanced Python unit testing framework for customer support tech enablement, covering FastAPI, SQLAlchemy, PostgreSQL, async operations, mocking, fixtures…

manutejот manutej★ 64 звезды на GitHub20 установок в других каталогах

Об этом скилле

pytest - Advanced Python Unit Testing for Customer Support

Overview

pytest is the industry-standard testing framework for Python applications, offering powerful features that enable comprehensive, maintainable, and scalable test suites. This skill focuses specifically on customer support tech enablement, providing patterns and practices for testing backend support systems, ticketing platforms, knowledge bases, and customer data platforms.

Customer support systems require rigorous testing due to their mission-critical nature. Downtime or bugs directly impact customer satisfaction, agent productivity, and business operations. This skill provides comprehensive guidance on testing all aspects of support systems using pytest.

Why pytest for Customer Support Systems

Unique Requirements

Customer support applications have specific testing needs:

  1. High Reliability: Support systems are mission-critical; failures directly affect customer experience
  2. Complex Data Relationships: Tickets, customers, agents, comments, attachments, and knowledge articles
  3. External Integrations: Email services (SendGrid, AWS SES), CRM systems (Salesforce, HubSpot), payment processors
  4. Async Operations: Background jobs, email queues, notification services, webhook deliveries
  5. Data Validation: Strict validation for customer PII, ticket priorities, SLA requirements, escalation rules
  6. Multi-tenancy: Isolation between different customer organizations or workspaces
  7. API-First Design: RESTful APIs requiring comprehensive endpoint coverage
  8. Real-time Features: WebSocket connections, live chat, real-time ticket updates
  9. Compliance: GDPR, CCPA, data retention policies, audit logging

pytest Advantages

pytest addresses these needs through:

  • Powerful Fixture System: Manage complex database setups, API clients, and test data
  • Parametrization: Test multiple scenarios efficiently (various ticket types, priority levels, user roles)
  • Rich Plugin Ecosystem: pytest-asyncio for async testing, pytest-mock for mocking, pytest-cov for coverage
  • Excellent Integration: Works seamlessly with FastAPI, SQLAlchemy, PostgreSQL, Pydantic
  • Clear Output: Readable test results and comprehensive error reporting
  • Scalability: Handles small test suites to thousands of tests with parallel execution
  • Flexibility: Supports unit, integration, and end-to-end testing in one framework

Core Competencies

1. Fixtures and Dependency Injection

Fixtures are pytest's killer feature, providing reusable setup/teardown logic and dependency injection. For customer support systems, fixtures manage databases, API clients, test data, and external service mocks.

Basic Fixtures

import pytest
from app.models import Ticket, Customer, Agent

@pytest.fixture
def support_ticket():
    """Provide a basic support ticket dictionary."""
    return {
        "id": 1,
        "title": "Cannot access account",
        "description": "User unable to login after password reset",
        "status": "open",
        "priority": "high",
        "customer_email": "[email protected]",
        "category": "authentication"
    }

def test_ticket_structure(support_ticket):
    """Test ticket has required fields."""
    assert support_ticket["status"] == "open"
    assert support_ticket["priority"] in ["low", "medium", "high", "critical"]
    assert "@" in support_ticket["customer_email"]

Fixture Scopes

Control when fixtures are created and destroyed using scopes:

  • function (default): Created once per test function, destroyed after test completes
  • class: Created once per test class, shared across all methods
  • module: Created once per module file, shared across all tests in file
  • package: Created once per package, shared across all tests in package
  • session: Created once per entire test session, shared across all tests
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session
from typing import Generator

@pytest.fixture(scope="session")
def database_engine():
    """Create database engine once per session."""
    engine = create_engine(
        "postgresql://support_user:password@localhost/support_test",
        echo=False,
        pool_pre_ping=True,
        pool_size=10,
        max_overflow=20
    )
    # Create all tables
    from app.database import Base
    Base.metadata.create_all(engine)

    yield engine

    # Cleanup: drop all tables and dispose engine
    Base.metadata.drop_all(engine)
    engine.dispose()

@pytest.fixture(scope="function")
def db_session(database_engine) -> Generator[Session, None, None]:
    """Create a new database session for each test with automatic rollback."""
    SessionLocal = sessionmaker(bind=database_engine)
    session = SessionLocal()

    try:
        yield session
    finally:
        session.rollback()  # Rollback any changes
        session.close()

Autouse

Полный SKILL.md на GitHub

Установить pytest в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

EXAMPLES.mdREADME.md

FAQ

Что делает скилл pytest?

Advanced Python unit testing framework for customer support tech enablement, covering FastAPI, SQLAlchemy, PostgreSQL, async operations, mocking, fixtures, parametrization, coverage, and comprehensive testing strategies for backend support systems

Как установить скилл pytest?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл pytest запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить pytest с