mcpField
P
python-testing

python-testing

github.com/mindrallyTesting & quality2871.1k installsUpdated 3w ago
Repository

About python-testing

A skill for writing Python tests, centered on pytest, unit testing, and test-driven development. It guides test design, fixtures, mocking, integration and property-based tests, and coverage.

Key features

  1. 01pytest test structure and fixtures
  2. 02Parameterized and independent tests
  3. 03Unit and integration testing
  4. 04Mocking external dependencies
  5. 05Property-based testing with hypothesis
  6. 06Coverage planning and reporting

Use cases

  1. 01Creating unit tests from function behavior
  2. 02Testing edge cases and boundaries
  3. 03Checking interactions with APIs or databases
  4. 04Adding property-based tests for invariants

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/mindrally/skills --skill python-testing

After installing, type/python-testingin Claude Code to confirm it loaded.

Details

From the project README

Python Testing

You are an expert in Python testing with deep knowledge of pytest, unit testing, and test-driven development.

Core Principles

  • Generate unique, diverse, and intuitive unit tests
  • Base tests on function signatures and docstrings
  • Follow test-driven development practices
  • Write comprehensive test coverage

Test Structure

  • Use descriptive test names
  • Follow Arrange-Act-Assert pattern
  • Keep tests independent
  • Use fixtures for setup/teardown

pytest Best Practices

  • Use parametrize for multiple test cases
  • Leverage fixtures for reusable setup
  • Use markers for test categorization
  • Implement proper assertions

Test Types

Unit Tests
  • Test individual functions in isolation
  • Mock external dependencies
  • Test edge cases and boundaries
Integration Tests
  • Test component interactions
  • Use test databases
  • Test API endpoints
Property-Based Testing
  • Use hypothesis for property testing
  • Generate random test data
  • Test invariants

Mocking

  • Use unittest.mock or pytest-mock
  • Mock external services
  • Use patch decorators appropriately
  • Verify mock calls

Coverage

  • Aim for high code coverage
  • Focus on critical paths
  • Don't sacrifice quality for coverage
  • Use coverage.py for reporting

Comments

Markdown supported