pytest

Standardizes pytest-based patterns for Python unit and integration testing.

618|89|Updated Jan 16, 2026
One-click install
npx skills add https://github.com/Gentleman-Programming/Gentleman-Skills --skill pytest-gentleman-programming
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest
Source: https://github.com/Gentleman-Programming/Gentleman-Skills/tree/main/curated/pytest
Command: npx skills add https://github.com/Gentleman-Programming/Gentleman-Skills --skill pytest-gentleman-programming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Python developers adopt pytest-based testing patterns to create robust, maintainable tests, reducing flaky behavior and speeding feedback cycles in CI.

Core Features & Use Cases

  • Fixtures for test setup and teardown
  • Mocking and patching for isolated units
  • Parametrization to cover multiple inputs efficiently
  • Markers and plugin usage to organize tests and extend capabilities
  • Async testing support with pytest-asyncio

Quick Start

Install pytest via pip, organize tests under a tests/ directory using pytest conventions, and run the tests with pytest. For example, write a test in tests/test_example.py and execute pytest to see results.

Frequently Asked Questions about pytest

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

FAQPage Schema
How do I write unit tests in Python with pytest?

pytest standardizes Python unit testing by organizing tests in a tests/ directory using simple assert statements. Install pytest via pip, write test functions prefixed with test_, and run pytest to execute them. It requires no boilerplate setup compared to other frameworks.

What are pytest fixtures and how do I use them for test setup?

Fixtures are reusable setup and teardown functions that prepare test data and clean up resources before and after tests run. Define them with @pytest.fixture decorator and pass them as parameters to test functions to reduce code duplication across tests.

How do I test multiple inputs efficiently without writing duplicate tests?

pytest parametrization lets you run the same test with different inputs using @pytest.mark.parametrize. This covers multiple scenarios in one test function, reducing code and improving maintainability across edge cases.

Can I mock external dependencies and isolate units in pytest?

pytest supports mocking and patching via the unittest.mock module and pytest plugins. Isolate units by replacing external calls with mock objects, verify they were called correctly, and test behavior in isolation without hitting real APIs or databases.

Does pytest work with asynchronous Python code?

pytest supports async testing through the pytest-asyncio plugin. Mark async test functions with @pytest.mark.asyncio and pytest handles event loop setup, enabling you to test async/await code and coroutines directly.

How do I organize and run specific test groups with pytest markers?

pytest markers like @pytest.mark.slow or @pytest.mark.integration categorize tests for selective execution. Run specific groups with pytest -m marker_name, enabling faster feedback cycles by skipping expensive tests during development.