Skip to main content

Pytest reporter for Flakiness.io

Project description

pytest-flakiness

The official Flakiness.io reporter for pytest.

[!TIP] Report demo is available at https://flakiness.io/flakiness/pytest-flakiness

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-report

[!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

To upload reports, you need 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 (recommended for CI/CD) 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-output-dir FLAKINESS_OUTPUT_DIR Local directory to save JSON report. Defaults to flakiness-report
--flakiness-access-token FLAKINESS_ACCESS_TOKEN Your Flakiness.io access token (required for upload)
--flakiness-endpoint FLAKINESS_ENDPOINT Flakiness.io service endpoint. Defaults to https://flakiness.io

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)

To ensure reports are uploaded during your CI runs, map the secret in your workflow:

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

Or use the command-line flag:

- name: Run Tests
  run: pytest --flakiness-access-token="${{ secrets.FLAKINESS_ACCESS_TOKEN }}"

🛠️ Development Setup

This project uses uv for dependency management and pre-commit for code quality checks.

1. Install Dependencies

Ensure you have uv installed, then run:

uv sync

2. Enable Git Hooks

This project uses ruff (formatting/linting) and pyright (type checking) as pre-commit hooks. You must install the git hooks to ensure checks run automatically before you commit:

uv run pre-commit install

3. (Optional) Run Checks Manually

You can trigger the full suite of checks on all files at any time:

uv run pre-commit run --all-files

Tests Dashboard

The tests dashboard is available at https://flakiness.io/flakiness/pytest-flakiness

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.10.0.tar.gz (10.6 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.10.0-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_flakiness-0.10.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.10.0.tar.gz
Algorithm Hash digest
SHA256 701fc2bfac27191a725fc73ba87de5b1e636c9b9931e9e39e2d1f986d6e65bcb
MD5 8e6837cbce618a17a6d3d01ff8a6e60b
BLAKE2b-256 e31514a0925793316a7ec66dbc596836a6eb45de7810d018607f388ff9d402c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pytest_flakiness-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","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.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afc1387acc4342aca6358895d6f9d18454813c1f3db13f2141d255a3386971f4
MD5 0eeafc1c503c324e22380eb80ee92742
BLAKE2b-256 14f280d6e7e609b5166350b5e8156bd23997954fef12ce1ef87a5f263e514798

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