Pytest patterns

From vladkesler/initrunner · View interactive version

Pytest patterns is an AI agent skill from the GitHub repository vladkesler/initrunner. Pytest best practices including fixtures, parametrize, markers, and assertion patterns for Python test suites.

How to use this skill

Skill file

Pytest patterns and best practices for Python test suites.

When to activate

Use this skill when the project has pyproject.toml, setup.cfg, pytest.ini,

conftest.py, or a tests/ directory containing *_test.py or test_*.py

files.

Test file structure

share setup or conceptually belong together.

like a specification (e.g. test_parse_config_raises_on_missing_key).

Fixtures

discovered by pytest.

module, session.

cleanup even if the test fails.

object creation per-call.

dependent test once per parameter value.

Parametrize

test once per tuple.

the cartesian product.

they reach the test.

Markers

pytest -m "not slow".

does not fail the suite.

to avoid warnings.

Assertions

exception type and message verification.

exception type.

Running

MUST

fail.

MUST NOT

capsys if output matters.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.