Skip to main content

pytest-flakelens

The pytest reporter for FlakeLens — a self-hosted test observability platform with AI agents that fix flaky tests, not just flag them.

This plugin streams your test results, retries, and Playwright artifacts (screenshots, traces) to a FlakeLens server as the run happens. It never fails your test session: if the server is unreachable, it logs one warning and gets out of the way.

Install

pip install pytest-flakelens

Use

Point it at your FlakeLens server and give it a project key (create a project in the FlakeLens dashboard to get one):

# pytest.ini  (or [tool.pytest.ini_options] in pyproject.toml)
[pytest]
flakelens_url = https://flakelens.your-company.com
export FLAKELENS_API_KEY=flk_your_project_key
pytest

That's it — every run now appears in your dashboard with run history, flaky-test scoring, failure records, and the AI analysis / auto-fix agents.

addopts = --screenshot only-on-failure --tracing retain-on-failure --reruns 2

Failure screenshots and Playwright traces are captured automatically; --reruns (via pytest-rerunfailures) feeds intra-run flaky detection.

Configuration

Setting (pytest.ini) Env var Default
flakelens_url FLAKELENS_URL
flakelens_api_key FLAKELENS_API_KEY
flakelens_enabled FLAKELENS_ENABLED auto (on when url + key are set)
flakelens_framework FLAKELENS_FRAMEWORK auto-detected
flakelens_batch_size FLAKELENS_BATCH_SIZE 20
flakelens_upload_artifacts FLAKELENS_UPLOAD_ARTIFACTS true

Branch/commit metadata is auto-read from GITHUB_* in CI (or set FLAKELENS_BRANCH / FLAKELENS_COMMIT).

Markers

  • @pytest.mark.quarantine — FlakeLens-managed: runs the test as a non-strict xfail so a known-flaky test stops blocking CI while the fix agent works on it, while still reporting its real pass/fail.

Attach files

def test_thing(testwarden_attach):
    testwarden_attach("path/to/file.png", kind="screenshot")

Not on pytest?

FlakeLens also ingests JUnit XML from any framework (Selenium/Java, Jest, Cypress, Go, .NET…) via a single upload — see the FlakeLens docs.

License

MIT

Release files for pytest-flakelens 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-flakelens 0.1.0
File Size Uploaded
pytest_flakelens-0.1.0.tar.gz 14.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-flakelens 0.1.0
File Interpreter ABI Platform
pytest_flakelens-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / pytest_flakelens-0.1.0.tar.gz

Download URL pytest_flakelens-0.1.0.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0d621ad0ba4351de24f5aca154ea4ad30e4b5f91ef9fe23d7a091de0c284fd41
BLAKE2b-256 checksum
How to use checksums
fa30fb022240d531dea47603ad11396f2628640c722b6a933db598fee997fd39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.4

Release files / pytest_flakelens-0.1.0-py3-none-any.whl

Download URL pytest_flakelens-0.1.0-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc52829476c39688da65ffd9f74cb6f7a59cdd1f325c94b3d1b89247d8fee560
BLAKE2b-256 checksum
How to use checksums
00f2ca61912dcd802f3fd36d6d449ae995a2e002a680c3091682798db2af0935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page