pytest-testing

Implement Python tests using the pytest framework with fixtures and mocking.

2|Updated Feb 15, 2026
One-click install
npx skills add https://github.com/nakano1122/dotfiles --skill pytest-testing-nakano1122
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-testing
Source: https://github.com/nakano1122/dotfiles/tree/main/dot_agents/skills/pytest-testing
Command: npx skills add https://github.com/nakano1122/dotfiles --skill pytest-testing-nakano1122

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive guide to implementing robust and efficient tests for Python applications using the pytest framework, ensuring code quality and reliability.

Core Features & Use Cases

  • Test Structure: Learn best practices for organizing tests and writing clear, maintainable test functions.
  • Fixtures: Master fixture creation and scoping for setup/teardown and dependency injection.
  • Parameterization & Mocking: Effectively use parameterization for diverse test cases and mocking for isolating dependencies.
  • FastAPI Integration: Understand how to test FastAPI applications using TestClient and httpx.AsyncClient.
  • Use Case: When developing a new Python API endpoint, use this Skill to write comprehensive unit and integration tests that cover various scenarios, including edge cases and error conditions, ensuring the endpoint functions as expected.

Quick Start

Use the pytest-testing skill to write a new test function for the calculate_total function in src/utils.py.

Frequently Asked Questions about pytest-testing

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

FAQPage Schema
How do I write integration tests for a FastAPI application using pytest?

FastAPI integration testing with pytest uses TestClient for synchronous requests and httpx.AsyncClient for asynchronous endpoints to verify API behavior. This Skill provides guides for setting up these clients to test endpoint scenarios comprehensively.

What is the best way to structure pytest fixtures for setup and teardown?

Pytest fixtures handle setup and teardown through dependency injection, allowing you to define reusable functions that provide resources to tests. This Skill covers fixture creation and scoping to manage test dependencies efficiently across your Python project.

How do I use parameterization and mocking in pytest to isolate dependencies?

Parameterization in pytest runs the same test across diverse inputs, while mocking with unittest.mock and pytest-mock isolates dependencies by replacing real objects. This Skill demonstrates combining both techniques to thoroughly cover edge cases and error conditions.

Can I generate coverage reports and use markers when testing Python code with pytest?

Coverage reporting measures which code lines your tests execute, and pytest markers allow you to categorize and selectively run specific test groups. This Skill explains configuring both features to ensure code quality and reliability during development.

Does pytest work well for testing both unit and integration scenarios in Python?

Pytest supports both unit testing for isolated functions and integration testing for combined components like FastAPI endpoints. This Skill outlines best practices for organizing these tests clearly to ensure maintainable and reliable Python projects.