Skip to main content
The Examples Runner provides a CLI command to discover, execute, and report on Python examples in your repository. It’s designed for CI/CD pipelines and local development with zero performance impact when not invoked.

Quick Start

Commands

Run Examples

Execute examples sequentially with live output streaming and report generation.
Options: Examples:

List Examples

Discover and list examples without executing them.
Options: Example:

Show Example Info

Display detailed metadata for a specific example.
Example:

Example Metadata Directives

Control example behavior using comment directives in the first 30 lines of your example files:

Available Directives

Auto-Detection

The runner automatically detects and skips:
  • Interactive examples: Files containing input() calls
  • Private files: Files starting with _ or __
  • Cache directories: __pycache__, .pytest_cache, etc.
  • Virtual environments: venv, .venv, env, .env

Reports

Report Directory Structure

JSON Report Schema

Markdown Report

The Markdown report includes:
  • Run metadata (timestamp, platform, versions)
  • Summary table with pass/fail/skip counts
  • Results table with status and duration
  • Detailed failure section with error summaries

Exit Codes

CI/CD Integration

GitHub Actions

GitLab CI

Best Practices

  1. Use metadata directives to document example requirements
  2. Set appropriate timeouts for long-running examples
  3. Use require_env to skip examples when API keys are missing
  4. Mark flaky tests with xfail to prevent CI failures
  5. Run with --fail-fast in CI for faster feedback
  6. Archive reports for debugging failed runs

Programmatic Usage