Metadata-Version: 2.4
Name: testfn
Version: 0.0.1
Summary: Comprehensive self-hosted testing platform for developers (Python SDK)
Project-URL: Documentation, https://docs.superfunctions.dev/testfn
Project-URL: Repository, https://github.com/21nCo/super-functions
Project-URL: Issues, https://github.com/21nCo/super-functions/issues
Author: 21n
License-Expression: MIT
Keywords: automation,superfunctions,test-runner,testing
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Requires-Dist: pillow>=10.0.0
Requires-Dist: pydantic>=2.5.0
Requires-Dist: sqlalchemy>=2.0.0
Provides-Extra: dev
Requires-Dist: black>=23.11.0; extra == 'dev'
Requires-Dist: mypy>=1.7.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
Requires-Dist: pytest>=7.4.0; extra == 'dev'
Requires-Dist: ruff>=0.1.6; extra == 'dev'
Description-Content-Type: text/markdown

# 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 `pytest` for 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

```bash
pip install testfn
```

## Quick Start

### Basic Test Execution

```python
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

```python
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

```python
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

```bash
# Setup virtual environment
python3 -m venv .venv
source .venv/bin/activate

# Install dependencies
pip install -e .[dev]

# Run tests
pytest
```

## License

MIT