pytest

Automate Python testing workflows with pytest fixtures, parametrization, and mocking.

Updated Mar 10, 2025
One-click install
npx skills add https://github.com/alvaldes/alvaldes.dots --skill pytest-alvaldes
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/alvaldes/alvaldes.dots/tree/main/opencode/skill/pytest
Command: npx skills add https://github.com/alvaldes/alvaldes.dots --skill pytest-alvaldes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pytest testing patterns help you standardize and accelerate Python test writing, ensuring consistent quality across projects.

Core Features & Use Cases

  • Fixtures and test structure for reliable setup and teardown
  • Parametrization, mocking, and markers to cover varied scenarios
  • Async tests and shared fixtures via conftest.py for scalable test suites

Quick Start

Run pytest to execute the tests and verify they pass across your Python project.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I standardize Python testing workflows using pytest patterns?

To standardize Python testing workflows, apply structured pytest templates for unit, integration, and async tests. This approach uses reusable fixtures, parametrization, and mocking to ensure consistent test quality and reliability across projects.

What is the best way to structure reusable pytest fixtures for scalable test suites?

The best way to structure reusable pytest fixtures is by defining shared fixtures and setup logic within a conftest.py file. This centralizes configuration and allows scalable test suites to share context across multiple test modules efficiently.

How do I parametrize Python tests to cover varied scenarios?

You parametrize Python tests by applying pytest parametrization patterns to pass multiple datasets into a single test function. This minimizes code duplication and systematically covers varied scenarios to validate behavior across different inputs.

Does pytest support mocking and async tests for Python projects?

Yes, pytest supports mocking and async tests within Python projects. The framework provides structured patterns to mock external dependencies and execute asynchronous test cases, ensuring reliable validation for modern async Python applications.

When do I need to use pytest markers in my test suite?

You need pytest markers when you want to categorize, select, or filter specific tests within your suite. Markers allow you to logically group tests, such as integration or unit tests, enabling targeted execution without running the entire suite.