test-writing

Standardize pytest conventions for Python test suites.

Updated Nov 11, 2025
One-click install
npx skills add https://github.com/libertininick/chain-reaction --skill test-writing-libertininick
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-writing
Source: https://github.com/libertininick/chain-reaction/tree/main/.claude/skills/test-writing
Command: npx skills add https://github.com/libertininick/chain-reaction --skill test-writing-libertininick

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Pytest conventions ensure tests are readable, maintainable, and reliable by enforcing consistent naming, structure, and use of fixtures and parametrization across a codebase.

Core Features & Use Cases

  • Test file naming: Use descriptive file names like test_module.py.
  • Test function naming: Follow the pattern test_<function><scenario><expected> to convey intent.
  • Structure and fixtures: Apply Arrange-Act-Assert, and use fixtures to share setup without repetition.
  • Parametrization and coverage: Use @pytest.mark.parametrize to run multiple inputs and promote thorough coverage.
  • Test classes and organization: Group related tests in classes to reuse fixtures and setup.

Quick Start

Use these conventions to structure pytest tests across your project, starting with renaming your test files to match the test_ naming pattern and refactoring test functions to follow the naming scheme. Then add fixtures and parametrization per the guidelines. Finally, run your tests with pytest to verify and iterate.

Frequently Asked Questions about test-writing

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

FAQPage Schema
How do I standardize pytest naming conventions across a Python project?

Standardize pytest naming by using descriptive test_module.py file names and structuring test functions with the test_<function>_<scenario>_<expected> pattern to convey clear intent and improve readability across your Python project.

What is the best way to organize pytest fixtures and test structure?

Organize pytest test structure by applying the Arrange-Act-Assert pattern and using fixtures to share setup without repetition. Group related tests in classes to reuse fixtures and setup across your Python test suite.

How do I use parametrization to improve pytest test coverage?

Improve pytest test coverage by using the @pytest.mark.parametrize decorator to run multiple inputs within a single test function. This promotes thorough coverage and ensures consistent test execution across various scenarios.

Can I perform multiple assertions in a single pytest test function?

Yes, you can perform multiple assertions in a single pytest test function. The conventions support multi-assert checks using the pytest-check plugin where appropriate, allowing you to evaluate multiple conditions within one test without stopping at the first failure.

Does enforcing pytest conventions work with existing Python test suites?

Yes, applying pytest conventions works with existing Python test suites. You can refactor current tests by renaming files to match the test_ pattern, updating function names, and adding fixtures and parametrization to standardize structure and intent.