Metadata-Version: 2.3
Name: pyveritas
Version: 0.1.2
Summary: A Python testing tool that combines fuzzing and traditional unit tests.
Author-email: Tim McCallum <mistermac2008@gmail.com>
Description-Content-Type: text/markdown
Requires-Dist: pytest >=7.0

# PyVeritas

Revolutionizing Python testing with adaptive, intelligent, and developer-friendly tools.

# 🚀 Overview

PyVeritas is an advanced software testing framework designed to push the boundaries of Python testing. By combining the precision of unit testing, the randomness of fuzzing, and the adaptability of AI, PyVeritas helps developers create robust, reliable, and high-quality Python code effortlessly.

PyVeritas is code-aware, behavior-driven, and environment-adaptive. It doesn’t just test your code—it learns from it, evolves with it, and ensures every corner is thoroughly validated.

# 🌟 Features

**Intelligent Fuzzing**: Automatically generates meaningful fuzzing inputs tailored to your specific code logic.

**Behavioural Validation**: Compare your program's outputs against expected behaviours using AI models.

**Dynamic Test Optimization**: Keeps your test suite lean and relevant by analyzing historical failures and code changes.

**Cross-Environment Simulation**: Test across multiple Python versions and runtime environments.

**Actionable Insights**: Provides real-time feedback on test coverage, bottlenecks, and high-risk areas.

# 🛠️ Installation

PyVeritas is easy to install via pip:

```bash
pip install pyveritas
```

# ✨ Quick Start

Example, testing a calculator function. Let's say you had a Python file called `test_suite.py` where you had implemented a `calculate_discount()` function. If you add the `run_tests()` and `run_fuzz_tests()`, as shown below, you could have a self-testing file (like this one) to improve the robustness of your code's execution:

```python
import argparse
from pyveritas import VeritasTestSuite, VeritasFuzzer

# Pre-existing function to test
def calculate_discount(price: float, discount: float) -> float:
    if price <= 0 or discount < 0 or discount > 100:
        raise ValueError("Invalid price or discount")
    return price * (1 - discount / 100)

def run_tests():
    # Test suite
    suite = VeritasTestSuite("DiscountCalculatorTests")
    
    suite.test("Discount calculation is correct", lambda: calculate_discount(100, 20) == 80)
    suite.test("Invalid discount should raise ValueError", lambda: calculate_discount(-10, 50), should_raise=ValueError)
    
    suite.run()  # Run the test suite
    suite.summary()  # Output the summary of the test suite

def run_fuzz_tests():
    # Fuzz tests
    fuzzer = VeritasFuzzer("DiscountCalculatorFuzzing")
    
    fuzzer.test(
        input_spec={
            "price": lambda: VeritasFuzzer.float_range(0, 1000),
            "discount": lambda: VeritasFuzzer.float_range(0, 100),
        },
        iterations=1000,
    )
    fuzzer.run(calculate_discount)  # Run the fuzz tests
    fuzzer.summary()  # Output the summary of the fuzz tests

def main():
    parser = argparse.ArgumentParser(description="Run tests or fuzz tests on your Python code.")
    parser.add_argument('action', choices=['test', 'fuzz'], help="Specify 'test' to run unit tests or 'fuzz' to run fuzzing tests.")
    args = parser.parse_args()
    
    if args.action == 'test':
        run_tests()
    elif args.action == 'fuzz':
        run_fuzz_tests()

if __name__ == "__main__":
    main()
```

When calling the `test` and `fuzz` as arguments, your code (example as shown above) will return something similar to the following:

```bash
$ python3 tests/test_suite.py test

Running test suite: DiscountCalculatorTests
Test 1 PASSED: Discount calculation is correct
Test 2 PASSED: Invalid discount should raise ValueError (Expected exception raised: Invalid price or discount)

----------------------------------------
Test Summary for Suite: DiscountCalculatorTests
Total Tests Run: 2
Passed: 2
Failed: 0
```

```bash
$ python3 tests/test_suite.py fuzz
Running fuzz tests on function: calculate_discount
Fuzzing iteration 1: PASSED with inputs {'price': 748.5057904261024, 'discount': 84.29362340396797}
Fuzzing iteration 2: PASSED with inputs {'price': 595.7437257017222, 'discount': 49.09955272366074}

...

Fuzzing iteration 999: PASSED with inputs {'price': 144.38623673700423, 'discount': 41.81132465276192}
Fuzzing iteration 1000: PASSED with inputs {'price': 934.2668869132724, 'discount': 48.77225754237649}

----------------------------------------
Fuzzing Summary for Function: DiscountCalculatorFuzzing
Total Iterations: 1000
Passed: 1000
Failed: 0
```

# 🧠 How It Works

## Code Analysis

PyVeritas inspects your code for patterns, structure, and dependencies.

## Test Generation

Automatically generates tests based on code analysis and input specifications.

## Execution

Runs the tests with real-time metrics on coverage and edge-case detection.

# Insights

Provides actionable feedback, including risk areas and potential optimizations.

# 🛡️ Why PyVeritas?
PyVeritas doesn’t just test—it thinks. By leveraging machine learning, dynamic adaptation, and intelligent fuzzing, PyVeritas ensures you catch bugs that other tools miss. Whether you’re developing simple scripts or large-scale applications, PyVeritas is your ultimate testing companion.

# 🏗️ Roadmap
- [ ] Build the foundational test suite framework.
- [ ] Integrate intelligent fuzzing with customizable input specifications.
- [ ] Develop AI-driven behavioural models for output validation.
- [ ] Add cross-environment compatibility testing.
- [ ] Create a comprehensive feedback and insights dashboard.
- [ ] Write comprehensive documentation
- [ ] Create contribution guide

# 📚 Documentation

Comprehensive documentation is available at PyVeritas Docs.

# 🖤 Contributing
Contributions are welcome! Please read our CONTRIBUTING.md for guidelines on how to get started.

# 📝 License

This project is licensed under the Apache2 License. See the LICENSE file for details.

