python-testing

Guide Python testing with pytest, TDD, fixtures, mocking, and coverage.

3|1|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN --skill python-testing-oabdelmaksoud
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN/tree/main/ecc-resources/docs/ja-JP/skills/python-testing
Command: npx skills add https://github.com/oabdelmaksoud/AGI-FARM-PLUGIN --skill python-testing-oabdelmaksoud

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a comprehensive strategy for writing robust and maintainable tests for Python applications, ensuring code quality and reliability.

Core Features & Use Cases

  • TDD Methodology: Guides users through the Red-Green-Refactor cycle for test-driven development.
  • pytest Best Practices: Covers fixtures, parameterization, mocking, and test selection.
  • Coverage: Emphasizes achieving high code coverage and provides commands to measure it.
  • Use Case: When developing a new feature, follow the TDD approach outlined here to write failing tests first, then implement the minimal code to pass, and finally refactor.

Quick Start

Use the python-testing skill to learn how to write a basic pytest test case.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I write parameterized tests in pytest to check multiple inputs?

Parameterized tests in pytest allow you to run the same test logic across multiple input combinations. You use the @pytest.mark.parametrize decorator to pass argument sets, reducing code duplication and ensuring comprehensive coverage for various scenarios.

What is the Red-Green-Refactor cycle in TDD?

The Red-Green-Refactor cycle in TDD involves writing a failing test first, implementing the minimal code required to make it pass, and then refactoring the code. This methodology ensures your development is driven by test requirements and maintains code quality.

How do I use pytest fixtures for setup and teardown operations?

Pytest fixtures provide a structured way to manage setup and teardown operations. By defining fixture functions, you can initialize resources, inject them into tests, and automatically clean up afterward, ensuring a maintainable and isolated testing environment.

Can I mock external calls when testing asynchronous code in Python?

You can mock external calls in asynchronous Python tests to isolate your code from external dependencies. This involves using mocking techniques to replace actual external calls, ensuring your tests remain reliable and focus solely on the logic of your asynchronous code.

What is the best way to measure code coverage in pytest?

To measure code coverage in pytest, you use specific commands that analyze which lines of code are executed during tests. Achieving high code coverage is emphasized to ensure your tests thoroughly validate the application's logic and reliability.