Adaptive random testing helpers for Python.
Project description
adaptive-testing-tools
Adaptive random testing helpers for generating spread-out random inputs and a few small random data utilities.
Installation
Install directly from the repository or a built wheel:
pip install .
Usage
from adaptive_testing_tools import random_choice, random_int, random_string
value = random_int(10, 99)
letter = random_choice(["a", "b", "c"])
token = random_string(length=12)
# Adaptive random testing with FSCs
from random import Random
from adaptive_testing_tools import adaptive_random_testing
def make_candidate(rng: Random) -> str:
# Example: random 4-word phrase; replace with your own generator
words = ["alpha", "bravo", "charlie", "delta", "echo", "foxtrot"]
return " ".join(rng.sample(words, 4))
def evaluate(candidate: str) -> bool:
# Replace with your system-under-test invocation
return "alpha" in candidate
samples = adaptive_random_testing(
make_candidate,
evaluate,
pool_size=5,
max_iterations=3,
seed=42,
)
for sample in samples:
print(sample.iteration, sample.distance_to_previous, sample.result)
Development
- Build artifacts:
python -m build - Install locally in editable mode:
pip install -e .
Feel free to extend the helpers in src/randomtest/generator.py to fit your projects.
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 adaptive_testing_tools-0.1.4.tar.gz.
File metadata
- Download URL: adaptive_testing_tools-0.1.4.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62bc350a00f76cfb4d15a0e7b4dfc0caa5591ce30279e193921ffeaf368616b0
|
|
| MD5 |
d22e280c940247e334e8a4e0f5a1da77
|
|
| BLAKE2b-256 |
106b2488336e7c279d2cb37d35b95fceeaf21bcb055ba1e9a5516f5a06cef92c
|
File details
Details for the file adaptive_testing_tools-0.1.4-py3-none-any.whl.
File metadata
- Download URL: adaptive_testing_tools-0.1.4-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d576e5c8e685f67abb1b642bce64c5a3931bd6af2b10d2e1425e2b12473411b2
|
|
| MD5 |
9c7d74f0ee86425d5a82145faabb637c
|
|
| BLAKE2b-256 |
8ca73795319f912a9ce345d413a1cee1284bbf2f3c96acf56464618a261d719c
|