Metadata-Version: 2.4
Name: testivai
Version: 0.1.0
Summary: Local-first visual regression capture for playwright-python and Selenium — pixel + DOM diff, tunable tolerances, PR approvals; shares baselines with the JS/TS TestivAI adapters
Project-URL: Homepage, https://github.com/mcbuddy/testivai-oss
Project-URL: Documentation, https://github.com/mcbuddy/testivai-oss/blob/main/docs/frameworks/python.md
Author: TestivAI
License: MIT
Keywords: playwright,pytest,screenshot-testing,selenium,testing,visual-regression
Classifier: Framework :: Pytest
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.9
Provides-Extra: playwright
Requires-Dist: playwright>=1.40; extra == 'playwright'
Requires-Dist: pytest-playwright>=0.4; extra == 'playwright'
Provides-Extra: selenium
Requires-Dist: selenium>=4.6; extra == 'selenium'
Description-Content-Type: text/markdown

# testivai (Python)

Local-first visual regression for **playwright-python** — pixel + DOM
comparison with tunable tolerances, a self-contained HTML report, and
PR-comment baseline approvals. Shares the exact on-disk contract with the
JS/TS TestivAI adapters, so mixed-language repos use **one set of baselines,
one report, one approval flow**.

```bash
pip install testivai[playwright]
```

## With pytest (pytest-playwright)

```python
def test_homepage(page, testivai_witness):
    page.goto("http://localhost:3000")
    testivai_witness(page, "homepage")
```

The bundled pytest plugin runs `testivai report` at session end: captures are
diffed against `.testivai/baselines/`, tolerances from `.testivai/config.json`
apply, and `visual-report/index.html` + `results.json` are written. Approve
baselines with `npx testivai approve --all` (or a `/testivai approve` PR
comment via the GitHub Action).

## Without pytest

```python
from testivai import witness, run_report

witness(page, "homepage", ignore_selectors=[".live-feed"], variant="firefox")
run_report()
```

## What captures do (identical to the JS adapters)

- **Stabilization by default**: animations/transitions complete instantly at
  their final state, caret hidden, web fonts awaited — the top causes of
  flaky visual diffs, neutralized.
- **`ignore_selectors`**: hidden from the pixels *and* excluded from the DOM
  snapshot (dynamic content never counts as a change).
- **`variant`**: folds into the snapshot name (`homepage__firefox`) so
  parallel browsers/viewports never overwrite each other's baselines.

The compare/report half runs via the `@testivai/witness` CLI — Node.js is
already present wherever playwright-python is (Playwright for Python ships a
Node driver). Resolution order: `TESTIVAI_CLI` env → `testivai` on PATH →
`npx --yes @testivai/witness`.

Docs: https://github.com/mcbuddy/testivai-oss/blob/main/docs/frameworks/python.md

MIT.
