pytest plugin that allows selectively running tests several times and accepting *some* failures.
Project description
pytest-stochastics
A pytest plugin for running stochastic tests with configurable policies.
Definition: Stochastic Test - A test that may occasionally fail due to the non-deterministic character of the test subject. Evaluated by an
at_leastof outout_ofmodel.
Features
- Run stochastic tests multiple times with customizable pass/fail criteria
- Configure different test plans with fallback options
Installation
You can install pytest-stochastics using pip:
pip install pytest_stochastics
Usage
Configuration
Create a pytest_stochastics.json file in your project root with your test configuration:
{
"test_plans": [
{
"plan": "weak",
"policy_tests": [
{
"policy": "always",
"tests": [
"tests/test_abc/test_1",
]
},
{
"policy": "mostly",
"tests": [
"tests/test_abc/test_2",
"tests/test_abc/test_3"
]
}
]
},
{
"plan": "strong",
"policy_tests": [
{
"policy": "always",
"tests": [
"tests/test_abc/test_2"
]
}
]
}
],
"policies": [
{
"policy": "always",
"at_least": 3,
"out_of": 3
},
{
"policy": "mostly",
"at_least": 2,
"out_of": 3
}
],
"plan_fallbacks": [
{
"plan": "strong",
"overrides": "weak"
}
]
}
Running Tests
Run your tests as usual with pytest:
pytest
You may override the default behaviour by defining a custom plan named
default.
To specify a plan:
pytest --plan="name of plan"
Project details
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 pytest_stochastics-0.4.1.tar.gz.
File metadata
- Download URL: pytest_stochastics-0.4.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.5 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb209eb33642d22fbd4bdf1fe528341aa4824e548c0689a4f4b00779252af2c8
|
|
| MD5 |
d11f06f0321cc7b26648595fe557e605
|
|
| BLAKE2b-256 |
c16c2ade36d58766d5c7d3e22eca7fb1de864de400753d01bb3fe70f32e818c7
|
File details
Details for the file pytest_stochastics-0.4.1-py3-none-any.whl.
File metadata
- Download URL: pytest_stochastics-0.4.1-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.5 Darwin/23.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b5eb9c2675f5e8ae5389b8a3c8bdf8b27e0ac64754f45005f2f643c6ab1bcda
|
|
| MD5 |
22e2bc9d19d8b7c116e72b9744d0a91e
|
|
| BLAKE2b-256 |
594b8cb74e9f6f6b462155af8e4ebe3302d2c4b2417684f9b5aeda8edb4009b6
|