python-package-testing

Create and run pytest test suites with coverage checks for Python packages.

Updated Apr 20, 2026
One-click install
npx skills add https://github.com/MLVisions/agentbuilder_py --skill python-package-testing-mlvisions
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-package-testing
Source: https://github.com/MLVisions/agentbuilder_py/tree/main/.github/skills/python-package-testing
Command: npx skills add https://github.com/MLVisions/agentbuilder_py --skill python-package-testing-mlvisions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-cov.

What problem does it solve? Writing consistent, thorough tests for Python packages is time-consuming, and gaps in coverage or weak assertions let bugs slip through when adding functions, fixing bugs, or refactoring code. ## Core Features & Use Cases - Pytest Test Authoring: Provides patterns for descriptive test names, one-concept-per-test structure, edge cases, and error message validation using pytest.raises and pytest.warns. - Coverage Analysis: Runs coverage reports with pytest --cov and applies guidelines such as 80%+ overall coverage and 100% for critical logic. - Docstring Example Validation: Executes public examples via pytest --doctest-modules to ensure documented usage actually works. - Use Case: After fixing a bug in an agent configuration loader, write a failing test first, implement the fix, run the full suite, and verify no retry-backoff warnings or masked failures appear. ## Quick Start Write a pytest test suite for my new function, run the full test suite with coverage, and fix any failures or warnings found.

Frequently Asked Questions about python-package-testing

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

FAQPage Schema
How do I write tests for a Python package with pytest?▼

Place test files in a tests/ directory with a conftest.py for shared fixtures, write descriptive test functions using plain assert statements, and run them with the pytest command. Group related tests in classes and test one concept per function.

How to check test coverage for a Python package?▼

Run pytest --cov=your_package --cov-report=term-missing to see line-by-line coverage in the terminal, or use --cov-report=html for a browsable report. Aim for 80%+ overall coverage and 100% on critical business logic.

How do I test that a function raises an error in pytest?▼

Use pytest.raises with a match pattern, for example with pytest.raises(ValueError, match="error message") around the failing call. For warnings, use pytest.warns with the expected warning class and message pattern.

Can pytest run examples in docstrings?▼

Yes, run pytest --doctest-modules on your source directory to execute docstring examples as tests. Examples requiring unavailable credentials or external APIs should be documented but excluded from automated execution.

Why do my tests show retry backoff waiting messages?▼

Retry backoff messages indicate an underlying design issue such as an agent calling a tool multiple times, excessive reasoning steps, or redundant API calls. Fix the root logic rather than suppressing the messages, and validate tool calls with thread inspection.