pytest

Automate unit testing for FastAPI and SQLAlchemy backend applications with pytest.

1|Updated Nov 18, 2025
One-click install
npx skills add https://github.com/manutej/crush-mcp-server --skill pytest
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/manutej/crush-mcp-server/tree/main/.claude/skills/pytest
Command: npx skills add https://github.com/manutej/crush-mcp-server --skill pytest

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill delivers comprehensive Python testing guidance using pytest for customer support systems, covering fixtures, parametrization, async tests, and CI integration to ensure robust, reliable software.

Core Features & Use Cases

  • Fixtures & Parametrization: Manage test data and scenarios efficiently.
  • Async Testing: Validate asynchronous endpoints and background tasks.
  • CI/CD Integration: Integrate tests into CI pipelines for quality gates.

Quick Start

Install pytest, write a simple test module, and run pytest to see detailed reports and coverage.

Frequently Asked Questions about pytest

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up pytest for testing FastAPI and SQLAlchemy applications?

Install pytest>=8.0.0 with plugins pytest-asyncio, pytest-cov, pytest-mock, and pytest-postgresql. Configure fixtures for database sessions, mock external services, and use pytest parametrization to test FastAPI endpoints and SQLAlchemy models across multiple scenarios efficiently.

Can I test asynchronous FastAPI endpoints and background tasks with pytest?

Yes. pytest-asyncio enables async test functions to validate asynchronous endpoints and background tasks. Mark tests with @pytest.mark.asyncio and use async fixtures to manage event loops and test async code in customer-support applications.

How do I integrate pytest into CI/CD pipelines for automated quality gates?

Configure pytest with coverage reporting (pytest-cov) and structured test organization to integrate into CI workflows. Run pytest in your pipeline to generate coverage reports, enforce test thresholds, and block deployments when quality gates fail.

What's the best way to test PostgreSQL transactions and multi-tenant data isolation?

Use pytest-postgresql to spin up isolated test databases per test run. Combine with SQLAlchemy fixtures and Alembic migrations to validate transaction handling, rollback behavior, and multi-tenant data flows without affecting production systems.

Do I need external mocking libraries alongside pytest for testing integrations?

pytest-mock provides built-in mocking via fixtures (monkeypatch and mocker), reducing external dependencies. For customer-support apps, mock external service integrations, API calls, and internal dependencies using pytest-mock without additional tools.