python-testing

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

1|Updated Feb 7, 2026
One-click install
npx skills add https://github.com/ndhananj/codex-agent-setup --skill python-testing-ndhananj
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/ndhananj/codex-agent-setup/tree/main/docs/zh-CN/skills/python-testing
Command: npx skills add https://github.com/ndhananj/codex-agent-setup --skill python-testing-ndhananj

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

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

Core Features & Use Cases

  • Test-Driven Development (TDD): Guides you through the Red-Green-Refactor cycle.
  • Pytest Framework: Leverages pytest's powerful features like fixtures, parametrization, and markers.
  • Mocking and Patching: Enables isolation of code under test by simulating external dependencies.
  • Coverage: Emphasizes achieving high code coverage for critical paths.
  • Use Case: When developing a new Python feature, use this Skill to write tests before writing the code, ensuring the feature behaves as expected and preventing regressions.

Quick Start

Use the python-testing skill to write a new unit test for the calculate_total function.

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I write Python tests using pytest fixtures and parametrization?

Python tests using pytest fixtures and parametrization are written by defining reusable setup functions and decorating test methods with multiple input combinations. This strategy enables comprehensive coverage across various scenarios without duplicating test code.

What is Test-Driven Development and how does it apply to Python testing?

Test-Driven Development is a methodology applying the Red-Green-Refactor cycle to Python testing. You write failing tests before implementing application code, ensuring features behave as expected and preventing regressions in critical paths.

How do I mock external calls when testing Python applications?

Mocking external calls when testing Python applications involves simulating dependencies to isolate the code under test. This approach uses patching techniques to replace external API interactions, ensuring tests run reliably without actual network requests.

Can I test asynchronous Python code and handle exceptions with pytest?

Testing asynchronous Python code and handling exceptions with pytest is fully supported. This strategy covers structuring async tests and asserting specific exception raises, ensuring reliable execution for concurrent application paths.

What is the best way to organize Python tests and ensure high code coverage?

The best way to organize Python tests and ensure high coverage involves structuring test directories logically and applying coverage measurement tools. This approach emphasizes validating critical paths while maintaining maintainable and efficient test suites.