Registry / testing / pytest-github-actions-annotate-failures

pytest-github-actions-annotate-failures

JSON →
library0.4.0pypypiunverified

A pytest plugin designed to enhance GitHub Actions workflows by annotating failed tests directly in the pull request or commit view. It parses pytest output and generates GitHub workflow commands to create inline annotations for test failures, providing immediate feedback on problematic code lines. The project is actively maintained under the pytest-dev organization, with its latest version being 0.4.0.

pip install pytest-github-actions-annotate-failures
INSTALL
IMPORT
SIG · PYTEST-GITHUB-ACTI
P
pytest-github-actions-annotate-failures
testingpythonv0.4.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates how to set up `pytest-github-actions-annotate-failures` in a basic GitHub Actions workflow. Once installed and integrated, failed tests will automatically produce inline annotations in your GitHub pull requests or commit details, pointing directly to the line of code that caused the failure. No special command-line flags are typically needed for activation, as pytest discovers the plugin automatically upon installation.

mkdir my_project cd my_project # Create a test file cat <<EOF > test_example.py def test_passing(): assert True def test_failing(): assert False EOF # Create GitHub Actions workflow file mkdir -p .github/workflows cat <<EOF > .github/workflows/ci.yml name: Test with Annotations on: [push, pull_request] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: '3.10' - name: Install dependencies run: pip install pytest pytest-github-actions-annotate-failures - name: Run tests with annotations run: pytest EOF # To see it in action, commit these files to a GitHub repository # and push. The workflow will run and failed tests will show # annotations in the 'Checks' or 'Actions' tab.
Debug
Known issues
breakingVersion 0.4.0 and later require Python >=3.10 and Pytest >=7.0.0. Older Python or Pytest versions are not supported and will likely lead to installation or runtime errors.
fix
Ensure your GitHub Actions workflow or local environment uses Python 3.10+ and pytest 7.0.0+.
affects: >=0.4.0
gotchaIf your tests are located in a subdirectory relative to the repository root (e.g., `src/tests/`), GitHub Actions may not correctly link annotations to the source files.
fix
Set the `PYTEST_RUN_PATH` environment variable to the path of your test directory relative to the repository root. For example, `env: PYTEST_RUN_PATH: src/tests` in your workflow step.
affects: All versions
breakingAs of version 0.4.0, when `pytest-github-actions-annotate-failures` is used in conjunction with `pytest-rerunfailures`, only the *final* test failure is annotated. In previous versions (0.3.0 and older), annotations were added for all failed runs, including intermediate reruns.
fix
If you relied on annotations for intermediate rerun failures, be aware of this change in behavior. There is no direct fix to revert to the old behavior; adapt your workflow expectations accordingly.
affects: >=0.4.0
Upgrade
Version history
0.4.0latest on PyPI · released Mar 2, 2026
Audit
Dependencies
pytestrequiredCore dependency as this is a pytest plugin.
Agent activity
11 hits · last 30 days
node
8
Resources
pytest-github-actions-annotate-failures — pip install pytest-github-actions-annotate-failures · libregistry