pytest

Write Python tests using pytest fixtures, mocking, parametrization, and markers.

1|Updated Jan 18, 2026
One-click install
npx skills add https://github.com/valec3/AGENTS.md --skill pytest-valec3
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/valec3/AGENTS.md/tree/main/REFERENCES/GentlemanProgramming/skill/pytest
Command: npx skills add https://github.com/valec3/AGENTS.md --skill pytest-valec3

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pytest provides a rich framework for Python testing; this Skill compiles best practices, patterns, and recipes to write reliable tests with fixtures, mocking, parameterization, and markers.

Core Features & Use Cases

  • Structured testing patterns: fixtures, mocks, parametrization, and marks for scalable test suites.
  • Training and quick-start examples: illustrates common pitfalls and how to organize tests for readability and maintainability.
  • Use Case: When starting a new Python project, apply these patterns to ensure tests cover unit behavior, integration points, and edge cases.

Quick Start

Run pytest in your project to execute tests; for example, pytest tests/ or pytest -k "test_user" to run a subset.

Frequently Asked Questions about pytest

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

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

To write reliable Python tests with pytest, apply structured patterns for fixtures, mocking, parametrization, and markers to cover unit behavior, integration points, and edge cases. This ensures scalable and maintainable test suites.

What is the best way to parametrize Python tests for edge cases?

The best way to parametrize Python tests is using the pytest parametrize marker, which allows you to run a single test function against multiple inputs. This pattern covers edge cases efficiently without duplicating test code.

Can I use pytest for async testing scenarios in Python?

Yes, pytest supports async testing scenarios in Python. The framework's patterns and conventions extend to asynchronous code, enabling you to write reliable tests for async functions using fixtures and markers within standard project setups.

How do I run a subset of pytest tests in my Python project?

To run a subset of pytest tests in your Python project, execute pytest with the -k flag followed by a keyword expression like "test_user". This filters and runs only matching tests, streamlining your testing workflow.

Do I need external runtime dependencies to use pytest patterns?

No, you do not need external runtime dependencies to use these pytest patterns. The Skill requires only Python and Pytest, supporting standard project setups with common testing utilities without introducing additional runtime dependencies.

How should I organize Python tests for readability and maintainability?

To organize Python tests for readability and maintainability, apply structured testing patterns using fixtures, mocks, parametrization, and markers. These conventions help avoid common pitfalls and ensure your test suites remain scalable.