python-testing-patterns

Write and run pytest tests with fixtures, mocking, and parametrization.

2|Updated Apr 6, 2026
One-click install
npx skills add https://github.com/bingeli1379/eli-marketplace --skill python-testing-patterns-bingeli1379
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing-patterns
Source: https://github.com/bingeli1379/eli-marketplace/tree/main/plugins/sdd-python/skills/python-testing-patterns
Command: npx skills add https://github.com/bingeli1379/eli-marketplace --skill python-testing-patterns-bingeli1379

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-cov, unittest.mock, pytest-mock, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill unit addresses the challenge of writing and maintaining tests for Python code using pytest, focusing on patterns such as fixtures, parametrization, mocking, and test-driven development.

Core Features & Use Cases

  • Pytest Mechanisms: Utilize pytest for writing and executing tests.
  • Fixtures and Parametrization: Implement test fixtures for setup/teardown and parametrization for varied input scenarios.
  • Mocking: Apply mocking to simulate external dependencies and test code isolation.
  • Use Case: It complements a test-driven development workflow, enabling you to write tests first and iteratively improve your code.

Quick Start

Run pytest test_example.py to execute unit tests in the directory.

Frequently Asked Questions about python-testing-patterns

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

FAQPage Schema
How do I write parameterized tests in pytest?

Parameterized tests in pytest allow you to execute the same test logic across varied input scenarios. This Skill implements parametrization to efficiently cover multiple test cases without duplicating test code.

What is the best way to mock external dependencies in Python unit testing?

Mocking external dependencies in Python unit testing is handled using unittest.mock and pytest-mock. This Skill applies mocking techniques to simulate external services, ensuring complete test code isolation.

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

Pytest fixtures provide a robust mechanism for test setup and teardown. This Skill utilizes fixtures to manage resource initialization and cleanup, supporting both integration and end-to-end testing workflows.

Does this testing approach support test-driven development practices?

Yes, this pytest testing approach fully supports test-driven development practices. It enables you to write tests first and iteratively improve your code through automated unit, integration, and end-to-end tests.

Do I need pytest plugins to run integration and end-to-end tests?

Yes, you need pytest and its plugins for mocking and testing. This Skill requires pytest, pytest-cov, pytest-mock, and unittest.mock to execute automated integration and end-to-end tests effectively.

Why does pytest test isolation fail when testing external services?

Pytest test isolation fails without properly mocking external dependencies. This Skill addresses these limitations by applying pytest-mock techniques to simulate external interactions and isolate the code under test.