pytest

Apply Pytest fixtures, mocking, parameterization, markers, and async test patterns.

2|Updated Jul 29, 2025
One-click install
npx skills add https://github.com/kurojs/ender4-dots --skill pytest-kurojs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/kurojs/ender4-dots/tree/main/.config/opencode/skill/pytest
Command: npx skills add https://github.com/kurojs/ender4-dots --skill pytest-kurojs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pytest testing patterns for Python enable writing clear, maintainable, and robust tests by leveraging fixtures, mocks, and parameterization to reduce boilerplate and improve test reliability.

Core Features & Use Cases

  • Fixtures: reusable setup for tests using fixtures and conftest.py.
  • Mocking & Patching: simulate complex dependencies with unittest.mock.
  • Parameterization & Markers: run multiple inputs and categorize tests for fast feedback.
  • Async Tests: test asynchronous code with pytest-asyncio patterns.
  • Test Discovery & Organization: structure tests for scalable projects.

Quick Start

Run pytest on your test suite to execute patterns like fixtures, mocking, and parameterization.

Frequently Asked Questions about pytest

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

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

Parameterized tests in pytest allow you to run the same test logic across multiple inputs by using the parametrize marker. This reduces boilerplate and improves test coverage by passing distinct data sets directly into your test functions.

What is a pytest fixture and when should I use conftest.py?

A pytest fixture provides reusable setup logic for your tests, while conftest.py organizes these fixtures across modules. You should use them to manage shared dependencies and initialize test states efficiently without duplicating code.

Can I test asynchronous Python code with pytest?

Yes, you can test asynchronous Python code with pytest by applying pytest-asyncio patterns. This involves marking async test functions so the framework can properly execute and await your coroutines during the test run.

How do I mock dependencies in Python tests using unittest.mock?

You mock dependencies in Python tests by using unittest.mock to patch complex objects. This simulates external interactions and isolates the specific code paths under test, ensuring reliable and focused test execution.

What is the best way to structure test discovery for scalable Python projects?

The best way to structure test discovery for scalable Python projects is to organize test files logically and use conftest.py hierarchies. This ensures pytest automatically discovers and executes tests while maintaining a maintainable project structure.