Comprehensive self-hosted testing platform for developers (Python SDK)
Project description
TestFn Python SDK
Comprehensive self-hosted testing platform for developers.
Overview
TestFn is a developer-first testing solution that combines test execution, analytics, and visual testing into a single self-hosted platform. This is the Python SDK for TestFn.
Features
- ✅ Test Execution: Integration with
pytestfor discovery and execution. - ✅ Storage: Persistent storage of test runs and results using SQLAlchemy (SQLite default).
- ✅ Analytics: Flaky test detection, performance regression analysis, and run metrics.
- ✅ Reporters: Console and JSON reporters for real-time and post-run output.
- ✅ Visual Testing: Pixel-by-pixel screenshot comparison and diff generation.
Installation
pip install testfn
Quick Start
Basic Test Execution
import asyncio
from testfn import test_fn
async def main():
# Initialize runner
runner = test_fn(framework="pytest")
# Run tests matching a pattern
run = await runner.run(["tests/**/*.py"])
print(f"Pass rate: {run.summary.passed / run.summary.total * 100}%")
if __name__ == "__main__":
asyncio.run(main())
Using Analytics
from testfn import Storage, AnalyticsEngine
async def analyze():
storage = Storage()
analytics = AnalyticsEngine(storage)
# Detect flaky tests
flaky = await analytics.detect_flaky("tests/test_ui.py::test_login")
print(f"Flaky Score: {flaky.flaky_score}")
print(f"Recommendation: {flaky.recommendation}")
# Find performance regressions
regressions = await analytics.find_regressions(
baseline_run_id="run-1",
current_run_id="run-2"
)
for reg in regressions:
print(f"Test {reg['test_id']} got {reg['change']:.1%} slower")
Visual Testing
from testfn import VisualTester
tester = VisualTester(baseline_dir="baselines", diff_dir="diffs")
# Compare two screenshots
passed, score, diff_path = tester.compare_screenshots(
current_path="screenshots/current.png",
name="homepage",
threshold=0.1
)
if not passed:
print(f"Visual regression detected! Diff at: {diff_path}")
Development
# Setup virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -e .[dev]
# Run tests
pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file testfn-0.0.1.tar.gz.
File metadata
- Download URL: testfn-0.0.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f62db85c9a1c1c4665a9931154b3e2156a6675445ef83a0ecd867ee6ccfdc5d
|
|
| MD5 |
f2fd00ce14a6eb777abd6e4d965870e0
|
|
| BLAKE2b-256 |
7a58c99d3a454dd4467c8f41893d986cb3b6735d1aed449a72b49e780e4ac92c
|
File details
Details for the file testfn-0.0.1-py3-none-any.whl.
File metadata
- Download URL: testfn-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12c8260aa4503021dbe144ffa5e5537a91d51faeff91a13ef40e902a3b7320f4
|
|
| MD5 |
f2ddc1134cfa47dad3df73a3dd30f4cc
|
|
| BLAKE2b-256 |
fd680e855627ea08a924681ed8f52fc61823674297b4288ef87ab836b45354f3
|