skillfed

python-testing

Learn to build robust test suites using pytest with fixtures at multiple scopes, parameterized test cases, and mocking strategies. This skill covers async testing patterns, FastAPI application testing, and property-based testing approaches to ensure comprehensive coverage and maintainable test code.

python-testing teaches you to write comprehensive pytest tests with fixtures, mocking, and async support following current best practices.

AI-generated summary based on this skill's SKILL.md

49 10 MIT updated by JosiahSiegel

Install

JosiahSiegel/claude-plugin-marketplace/python-testing · repository language: Shell

git clone https://github.com/JosiahSiegel/claude-plugin-marketplace
cp -r claude-plugin-marketplace/plugins/python-master/skills/python-testing ~/.claude/skills/python-testing
npx skillfed install JosiahSiegel/claude-plugin-marketplace/python-testing

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I write pytest tests with fixtures and best practices?

python-testing teaches you to structure pytest tests using fixtures at multiple scopes (function, class, session, module). Best practices include organizing tests in conftest.py, using the Arrange-Act-Assert pattern, parameterizing test cases with @pytest.mark.parametrize, and leveraging fixture dependencies. The skill emphasizes clear test naming, isolated test cases, and proper setup/teardown management to create maintainable, robust test suites.

What's the best way to mock external APIs in Python tests?

python-testing covers mocking external dependencies and APIs using pytest-mock and unittest.mock. You'll learn to patch functions and methods, create Mock objects with return values, and verify call counts and arguments. The skill shows how to mock HTTP requests in FastAPI tests using httpx, configure mock side effects for error scenarios, and isolate your code from external services to ensure fast, reliable unit tests.

How can I test async code and FastAPI applications?

python-testing includes async testing patterns using pytest-asyncio. You'll learn to mark async test functions with @pytest.mark.asyncio, test FastAPI endpoints with httpx's AsyncClient, and handle async fixtures. The skill covers testing async dependencies, mocking async functions, and validating response status codes and JSON payloads in FastAPI applications without running a live server.

How do I configure code coverage and organize tests?

python-testing teaches coverage setup using pytest-cov, including pyproject.toml configuration for coverage thresholds and report formats. Test organization strategies include grouping tests by module, using pytest markers to categorize tests (unit, integration, slow), and skipping tests conditionally. The skill helps you structure test directories, manage test dependencies, and generate coverage reports to track code quality.

What are pytest parametrize examples and when should I use them?

python-testing demonstrates @pytest.mark.parametrize to run the same test with multiple input combinations, reducing code duplication. Examples include testing functions with various valid/invalid inputs, edge cases, and different data types. Parametrization pairs with fixtures for powerful test generation, allowing you to test comprehensive scenarios efficiently while keeping test code DRY and readable.

How does property-based testing with Hypothesis improve my tests?

python-testing introduces property-based testing using Hypothesis to generate random test inputs automatically. Instead of writing specific test cases, you define properties your code should satisfy for any valid input. Hypothesis finds edge cases and shrinks failures to minimal examples, catching bugs traditional unit tests miss. This strategy complements snapshot testing for regression detection and comprehensive test coverage.

SKILL.md

rendered from the published skill — quoted content, verbatim

Quick Reference

pytest Command Purpose
pytest Run all tests
pytest -v Verbose output
pytest -k "name" Run tests matching pattern
pytest -x Stop on first failure
pytest --lf Run last failed
pytest -n auto Parallel execution
Fixture Scope Duration
function Per test (default)
class Per test class
module Per test file
session Entire test run
Mock Pattern Code
Patch function mocker.patch("module.func")
Return value mock.return_value = {...}
Side effect `mock.side_effect = [a, b,

(truncated - see the full file via the links below)

Read as markdown · JSON record · Browse the source repository

File tree — 2 files
plugins/python-master/skills/python-testing/SKILL.md
plugins/python-master/skills/python-testing/references/pytest-fixtures-cookbook.md

Related skills

Tags

test-automation mock-patching async-testing coverage-metrics fixture-patterns parametrized-testing property-based-testing snapshot-validation test-organization ci-cd-ready