pytest

Automate Python testing workflows with reusable pytest fixtures and patterns.

Updated Apr 9, 2025
One-click install
npx skills add https://github.com/D4nitrix13/dotfiles-tmp --skill pytest-d4nitrix13
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/D4nitrix13/dotfiles-tmp/tree/main/.config/opencode/skill/pytest
Command: npx skills add https://github.com/D4nitrix13/dotfiles-tmp --skill pytest-d4nitrix13

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Automates Python testing workflows by providing reusable pytest patterns and fixtures to speed up development and ensure reliability.

Core Features & Use Cases

  • Fixtures and test data management: reusable fixtures to supply test data and manage setup/teardown.
  • Mocking and patching: isolate units with mocks and monkeypatching.
  • Parametrize and markers: run parameterized tests and organize with markers for selective execution.
  • Async testing support: write async pytest tests to cover asynchronous code paths.

Quick Start

Create a simple test using a fixture to verify a function's behavior.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I write reusable pytest fixtures for test data management?

To write reusable pytest fixtures, define functions that supply test data and manage setup/teardown. Inject these fixtures into your unit and integration tests to consistently initialize resources and ensure reliable test execution.

What is the best way to isolate units with mocking and monkeypatching in Python tests?

To isolate units with mocking in Python tests, use monkeypatching to replace dependencies during test execution. This approach prevents external side effects and ensures your unit tests remain focused on the component under test.

How do I run parameterized tests and organize them with markers in pytest?

You can run parameterized tests by applying the parametrize decorator to pass multiple inputs to a single test function. Organize these tests using markers to enable selective execution based on specific attributes or categories.

Does pytest work with asynchronous code paths for async testing?

Yes, pytest supports writing async tests to cover asynchronous code paths. You can leverage specific async testing patterns and fixtures to validate your asynchronous Python functions effectively.

Can I use pytest patterns for both unit and integration tests in a Python project?

Yes, pytest patterns support both unit and integration tests in Python projects. You can apply reusable fixtures, mocking, and parameterization to streamline testing workflows across different test scopes and ensure software reliability.