{"library":"pytest-examples","title":"pytest-examples","description":"pytest-examples is a pytest plugin designed for testing Python code examples found within docstrings and markdown files. It can lint these code examples using tools like ruff and black, run them to verify their correctness, and even check if print statements are inlined as expected. The library is currently at version 0.0.18 and follows an active development and release cadence, often aligning with its upstream `pytest` and `pydantic` projects.","language":"python","status":"active","last_verified":"Sat May 16","install":{"commands":["pip install pytest-examples"],"cli":null},"imports":["import pytest"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import pytest\n\n# my_lib.py (example code to be tested)\ndef add_two_things(a, b):\n    \"\"\"\n    Adds two things.\n\n    >>> add_two_things(1, 2)\n    3\n    \"\"\"\n    return a + b\n\n# test_my_lib.py (pytest test file)\ndef test_add_two_things_example():\n    # This test primarily ensures pytest-examples is installed and discoverable.\n    # The actual testing of examples is done by running `pytest`.\n    pass\n\n# To run tests and check examples:\n# 1. Save the above code into 'my_lib.py' and 'test_my_lib.py'\n# 2. Run from your terminal in the same directory: pytest --py-examples\n# 3. To lint and run, and optionally update: pytest --py-examples --update-examples\n","lang":"python","description":"To use `pytest-examples`, ensure it is installed alongside `pytest`. The plugin automatically discovers code examples in docstrings (like the `add_two_things` function above) and markdown files. You typically invoke `pytest` with specific flags to enable `pytest-examples`'s features. The `--py-examples` flag enables example collection and running, and `--update-examples` enables in-place updates for formatting and print statement checks.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-16","installed_version":"0.0.18","pypi_latest":"0.0.18","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":4,"avg_import_s":0.44,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.43,"mem_mb":12.2,"disk_size":"34.9M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.3,"import_time_s":0.31,"mem_mb":12.2,"disk_size":"40M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.58,"mem_mb":12.9,"disk_size":"38.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.8,"import_time_s":0.48,"mem_mb":12.9,"disk_size":"44M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.51,"mem_mb":12.8,"disk_size":"30.0M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.4,"import_time_s":0.49,"mem_mb":12.8,"disk_size":"35M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.46,"mem_mb":11.8,"disk_size":"29.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.5,"import_time_s":0.42,"mem_mb":11.8,"disk_size":"35M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.37,"mem_mb":11.2,"disk_size":"34.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"pytest-examples","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":5,"import_time_s":0.36,"mem_mb":11.2,"disk_size":"39M"}]}}