pytest-fixtures

Automate pytest fixture setup with conftest files and parametrize decorators.

187|20|Updated Nov 20, 2025
One-click install
npx skills add https://github.com/TheBushidoCollective/han --skill pytest-fixtures
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pytest-fixtures
Source: https://github.com/TheBushidoCollective/han/tree/main/jutsu/jutsu-pytest/skills/pytest-fixtures
Command: npx skills add https://github.com/TheBushidoCollective/han --skill pytest-fixtures

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides structured fixtures and configuration to prepare and reuse test data and state across tests.

Core Features & Use Cases

  • Fixtures & Scopes: Session, module, function scopes for test data lifecycle.
  • conftest: Centralized fixtures and configuration.
  • Parametrization: Use parametrize to cover multiple cases efficiently.

Quick Start

Create a conftest that defines a session-scoped fixture and a parametric test.

Frequently Asked Questions about pytest-fixtures

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

FAQPage Schema
How do I set up pytest fixtures to reuse test data across multiple tests?

Pytest fixtures are reusable functions that prepare test data and state. Define them in a conftest.py file or in your test module using the @pytest.fixture decorator, then pass the fixture name as a parameter to your test functions. Fixtures automatically inject their return value into tests, eliminating duplicate setup code.

What's the difference between function, module, and session fixture scopes in pytest?

Fixture scope controls how long a fixture's state persists. Function scope (default) creates a fresh instance for each test; module scope reuses it across all tests in one file; session scope maintains it across your entire test run. Choose based on whether you need isolation or efficiency for expensive setup operations.

How do I use parametrize to run the same test with multiple inputs?

The @pytest.mark.parametrize decorator lets you specify multiple input sets for a single test function. List parameter names and values, and pytest runs your test once for each combination. This eliminates repetitive test functions and ensures consistent coverage of edge cases.

Can I share fixtures across multiple test files using conftest?

Yes. Create a conftest.py file at your project root or in any subdirectory, define fixtures there, and pytest automatically discovers and makes them available to all test files in that directory and below. This centralizes fixture logic and eliminates duplication across your test suite.

What happens if a fixture depends on another fixture in pytest?

Pytest fixtures can request other fixtures as parameters, creating a dependency chain. Pytest resolves the chain automatically, running dependencies first and passing their return values down. This enables composable, layered setup without manual sequencing.

When should I use fixture cleanup and teardown logic?

Use yield in a fixture to run cleanup code after each test. Code before yield is setup; code after yield is teardown. This ensures resources like database connections, temp files, or mocks are properly released, preventing test pollution and resource leaks.