aiskillstore/marketplace / skills/0xdarkmatter/python-pytest-patterns
python-pytest-patterns
Verifiedpytest testing patterns for Python. Triggers on: pytest, fixture, mark, parametrize, mock, conftest, test coverage, unit test, integration test, pytest.raises.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.9 KB |
| assets/conftest.py.template | other | 5.7 KB |
| assets/pytest.ini.template | other | 996 B |
| references/async-testing.md | markdown | 6.6 KB |
| references/coverage-strategies.md | markdown | 5.5 KB |
| references/fixtures-advanced.md | markdown | 5.2 KB |
| references/integration-testing.md | markdown | 8.2 KB |
| references/mocking-patterns.md | markdown | 6.6 KB |
| references/property-testing.md | markdown | 8.3 KB |
| references/test-architecture.md | markdown | 8.7 KB |
| scripts/generate-conftest.sh | script | 5.1 KB |
| scripts/run-tests.sh | script | 2.0 KB |
| skill-report.json | config | 93.1 KB |
scripts/run-tests.sh
View on GitHub#!/bin/bash
# Run pytest with recommended options
# Usage: ./run-tests.sh [options]
#
# Options:
# --quick Skip slow tests, minimal output
# --coverage Run with coverage report
# --watch Watch mode with pytest-watch
# --failed Re-run only failed tests
# --debug Enable debug output
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
# Default options
PYTEST_ARGS="-v"
COVERAGE=""
WATCH=""
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--quick)
PYTEST_ARGS="-q -x --tb=short"
shift
;;
--coverage)
COVERAGE="--cov=src --cov-report=term-missing --cov-report=html"
shift
;;
--watch)
WATCH=1
shift
;;
--failed)
PYTEST_ARGS="$PYTEST_ARGS --lf"
shift
;;
--debug)
PYTEST_ARGS="$PYTEST_ARGS -s --tb=long"
shift
;;
*)
PYTEST_ARGS="$PYTEST_ARGS $1"
shift
;;
esac
done
# Check if pytest is installed
if ! command -v pytest &> /dev/null; then
echo -e "${RED}pytest not found. Install with: pip install pytest${NC}"
exit 1
fi
# Watch mode
if [[ -n "$WATCH" ]]; then
if ! command -v ptw &> /dev/null; then
echo -e "${YELLOW}pytest-watch not found. Installing...${NC}"
pip install pytest-watch
fi
echo -e "${GREEN}Starting watch mode...${NC}"
ptw -- $PYTEST_ARGS $COVERAGE
exit 0
fi
# Run tests
echo -e "${GREEN}Running pytest...${NC}"
echo "pytest $PYTEST_ARGS $COVERAGE"
echo ""
pytest $PYTEST_ARGS $COVERAGE
# Open coverage report if generated
if [[ -n "$COVERAGE" ]] && [[ -f "htmlcov/index.html" ]]; then
echo ""
echo -e "${GREEN}Coverage report: htmlcov/index.html${NC}"
if command -v open &> /dev/null; then
read -p "Open coverage report? [y/N] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
open htmlcov/index.html
fi
fi
fi
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 318k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |