Skip to main content

Pytest reporter for Flakiness.io

Project description

Tests

pytest-flakiness

The official Flakiness.io reporter for pytest.

[!TIP]

Installation

Install using uv (recommended):

uv add --dev pytest-flakiness

Or via standard pip:

pip install pytest-flakiness

Usage

Once installed, simply run pytest. The reporter will automatically activate, aggregate test results, and create Flakiness Report in the flakiness-report directory.

pytest

The generated report can be viewed interactively via the Flakiness CLI Tool:

flakiness show

[!TIP] Make sure to add flakiness-report directory to your .gitignore

flakiness-report/

If Flakiness Access Token is passed, then the reporter will upload the report to Flakiness.io. You will see a confirmation in your terminal summary:

...
PASSED [100%]
==============================
✅ [Flakiness] Report uploaded: https://flakiness.io/your_org/your_proj/run/1
==============================

Uploading Reports to Flakiness.io

Github Actions

When running in GitHub Actions, the reporter can authenticate using GitHub's OIDC token — no access token needed.

For this to work:

  1. The GitHub Actions workflow must have id-token: write permission.
  2. The --flakiness-project option (or FLAKINESS_PROJECT env variable) must be set to your Flakiness.io project identifier (org/project).
  3. The Flakiness.io project must be bound to the GitHub repository that runs the GitHub Actions workflow.
permissions:
  id-token: write

steps:
  - name: Run Tests
    run: pytest --flakiness-project="my-org/my-project"

You can also use the FLAKINESS_PROJECT environment variable instead of the CLI flag:

permissions:
  id-token: write

steps:
  - name: Run Tests
    env:
      FLAKINESS_PROJECT: my-org/my-project
    run: pytest

Access Token

Alternatively, you can authenticate using your project's Access Token. You can find this in your project settings on flakiness.io.

Set the Access Token using either an environment variable or command-line flag:

export FLAKINESS_ACCESS_TOKEN="flakiness-io-..."
pytest --flakiness-access-token="flakiness-io-..."

All Configuration Options

All options can be set via environment variables or command-line flags:

Flag Environment Variable Description
--flakiness-name FLAKINESS_NAME Name for this environment. Defaults to pytest
--flakiness-title FLAKINESS_TITLE Optional human-readable report title. Typically used to name a CI run, matrix shard, or other execution group
--flakiness-output-dir FLAKINESS_OUTPUT_DIR Local directory to save JSON report. Defaults to flakiness-report
--flakiness-project FLAKINESS_PROJECT Flakiness.io project identifier (e.g. org/project). Required for GitHub OIDC authentication
--flakiness-access-token FLAKINESS_ACCESS_TOKEN Your Flakiness.io access token for upload
--flakiness-endpoint FLAKINESS_ENDPOINT Flakiness.io service endpoint. Defaults to https://flakiness.io
--flakiness-disable-upload FLAKINESS_DISABLE_UPLOAD Disable uploading the report to Flakiness.io. The JSON report is still written to the output directory

Custom Environment Data

You can add custom metadata to your test runs using FK_ENV_* environment variables. These might be handy to capture properties that affect system-under-test.

export FK_ENV_GPU_TYPE="H100"
export FK_ENV_DEPLOYMENT="staging"

The FK_ENV_ prefix is removed and keys are lowercased, e.g. FK_ENV_DEPLOYMENT becomes deployment, and FK_ENV_GPU_TYPE becomses gpu_type.

Local Development

To save reports locally, pass --flakiness-output-dir:

pytest --flakiness-output-dir=./flakiness-reports

This will create a report.json file and an attachments/ directory in the specified folder.

CI/CD Example (GitHub Actions)

Using GitHub OIDC (recommended — no secrets needed):

permissions:
  id-token: write

steps:
  - name: Run Tests
    run: pytest --flakiness-project="my-org/my-project"

Alternatively, using an access token:

- name: Run Tests
  env:
    FLAKINESS_ACCESS_TOKEN: ${{ secrets.FLAKINESS_ACCESS_TOKEN }}
  run: pytest

Contributing

See CONTRIBUTING.md for development setup, running checks, and publishing new versions.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_flakiness-0.18.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_flakiness-0.18.0-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file pytest_flakiness-0.18.0.tar.gz.

File metadata

  • Download URL: pytest_flakiness-0.18.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_flakiness-0.18.0.tar.gz
Algorithm Hash digest
SHA256 a43a0bef006555cc5c13133baba4a703b9176de9d1f1f4b8b35991d2130ff859
MD5 0ac1bfe80e11021fcfc49e3c48df817e
BLAKE2b-256 8f5d694408e412102d0f1b5b62e30c845a08401543292402fe1333fb81bb39a7

See more details on using hashes here.

File details

Details for the file pytest_flakiness-0.18.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_flakiness-0.18.0-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pytest_flakiness-0.18.0-py3-none-any.whl
Algorithm Hash digest
SHA256 920e53316fe5bcbfd7560a5970a8ea12b18f2d688434a41cec806a5d163740e9
MD5 588b95ff7386053ab35a75fb758f5566
BLAKE2b-256 d9b6083565b34fcf5c208d85d8c79d1e4088f876497b206d84254ece415f549e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page