Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
cfircoo avatar

Pytest Best Practices

  • 20 installs
  • 17 repo stars
  • Updated March 28, 2026
  • cfircoo/claude-code-toolkit

Automate pytest best practices in your development workflow

About

pytest-best-practices provides specialized automation for your workflow. Integrate it during build to automate key development tasks and improve team efficiency.

  • Pytest Best Practices
  • Automation
  • Workflow

Pytest Best Practices by the numbers

  • 20 all-time installs (skills.sh)
  • Ranked #10,442 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Jul 28, 2026 (Skillselion catalog sync)
npx skills add https://github.com/cfircoo/claude-code-toolkit --skill pytest-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs20
repo stars17
Last updatedMarch 28, 2026
Repositorycfircoo/claude-code-toolkit

What it does

Automate pytest best practices in your development workflow

Files

SKILL.mdMarkdownGitHub ↗

<objective> Provide pytest best practices and patterns for writing maintainable, efficient tests. </objective>

<essential_principles>

Test Independence

  • Each test must run in isolation - no shared state between tests
  • Use fixtures for setup/teardown, never class-level mutable state
  • Tests should pass regardless of execution order

Naming Conventions

  • Files: test_*.py or *_test.py
  • Functions: test_<description>()
  • Classes: Test<ClassName>
  • Fixtures: descriptive lowercase_with_underscores

Directory Structure

tests/
├── conftest.py          # Shared fixtures
├── unit/
│   └── test_module.py
├── integration/
│   └── test_api.py
└── fixtures/            # Test data files

Core Testing Rules

  • Use plain assert statements (pytest provides detailed failure messages)
  • One logical assertion per test when practical
  • Test edge cases: empty inputs, boundaries, invalid data, errors
  • Keep tests focused and readable

</essential_principles>

<quick_reference>

PatternUse Case
@pytest.fixtureSetup/teardown, dependency injection
@pytest.mark.parametrizeRun test with multiple inputs
@pytest.mark.skipSkip test temporarily
@pytest.mark.xfailExpected failure (known bug)
pytest.raises(Exception)Test exception raising
pytest.approx(value)Float comparison
mocker.patch()Mock dependencies
conftest.pyShare fixtures across modules

Common Commands

pytest -v                    # Verbose
pytest -x                    # Stop on first failure
pytest --lf                  # Run last failed
pytest -k "pattern"          # Match test names
pytest -m "marker"           # Run marked tests
pytest --cov=src             # Coverage report

</quick_reference>

<routing>

Based on what you're doing, read the relevant reference:

TaskReference
Setting up fixtures, scopes, factoriesreferences/fixtures.md
Parametrizing tests, multiple inputsreferences/parametrization.md
Mocking, patching, faking dependenciesreferences/mocking.md
Markers, exceptions, assertions, asyncreferences/patterns.md

</routing>

<dependencies>

pip install pytest pytest-asyncio pytest-mock pytest-cov pytest-xdist

</dependencies>

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.