python-testing

Configure pytest fixtures, mocking, async tests, and coverage via conftest.py.

8|Updated Nov 4, 2025
One-click install
npx skills add https://github.com/ilude/claude-code-config --skill python-testing-ilude
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-testing
Source: https://github.com/ilude/claude-code-config/tree/main/skills/python-testing
Command: npx skills add https://github.com/ilude/claude-code-config --skill python-testing-ilude

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Python developers adopt testing practices tailored for pytest, including fixtures, mocking, asynchronous testing, coverage configuration, and uv execution rules, reducing debugging time and increasing test reliability.

Core Features & Use Cases

  • Pytest fixtures & conftest patterns: manage setup/teardown at session/module/class/function scope.
  • UV execution rules: Always run tests via uv run pytest to ensure consistent environments.
  • Parametrized and async testing: verify multiple inputs and asynchronous code paths efficiently.
  • Coverage configuration: integrate with coverage reports to monitor test quality.

Quick Start

Run your Python test suite with UV: uv run pytest -v

Frequently Asked Questions about python-testing

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

FAQPage Schema
How do I set up pytest fixtures for test configuration and teardown?

Pytest fixtures manage setup and teardown across function, class, module, and session scopes defined in conftest.py. Define fixtures with @pytest.fixture decorator, specify scope parameter, and use them as test function arguments to automate initialization and cleanup workflows.

Why should I run Python tests with uv instead of pytest directly?

Running tests via `uv run pytest` ensures consistent isolated environments and dependency resolution. UV manages Python version and package isolation, preventing environment drift and making test results reproducible across machines.

How do I test asynchronous Python code with pytest?

Async testing uses pytest plugins like pytest-asyncio to handle coroutines. Mark async test functions with @pytest.mark.asyncio, define async fixtures with scope parameters, and pytest executes them in the event loop without manual setup.

Can I parameterize tests to verify multiple inputs efficiently?

Pytest parametrization uses @pytest.mark.parametrize decorator to run a test function across multiple input sets defined as tuples or lists. This reduces code duplication and provides clear test reports showing each input combination's result.

How do I configure test coverage reporting in a pytest project?

Configure coverage in pyproject.toml or .coveragerc with pytest-cov plugin. Specify source directories, omit patterns, and branch coverage settings; run `uv run pytest --cov` to generate coverage reports and monitor test quality.

What's the best way to mock dependencies in pytest tests?

Use unittest.mock.patch or pytest fixtures with monkeypatch to isolate code under test. Mock external services, APIs, and dependencies as fixtures scoped appropriately, injecting them into test functions to verify behavior without side effects.