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_least
of outout_of
model.
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 git+https://github.com/emcie-co/pytest-stochastics.git#egg=pytest_stochastics
# or
pip install git+ssh://git@github.com/emcie-co/pytest-stochastics.git#egg=pytest_stochastics
Or if you're using Poetry:
poetry add git+https://github.com/emcie-co/pytest-stochastics.git
# or
poetry add git+ssh://git@github.com/emcie-co/pytest-stochastics.git
Usage
Configuration
Create a pytest_stochastics_config.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
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
File details
Details for the file pytest_stochastics-0.3.0.tar.gz
.
File metadata
- Download URL: pytest_stochastics-0.3.0.tar.gz
- Upload date:
- Size: 6.3 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 | 88562cc0b3f4a17184d4e1c7bcc3300f481b01361f5d927212acca80e9ad5788 |
|
MD5 | 32907aaa666034a86272ffea2f9fb61d |
|
BLAKE2b-256 | aa168487dc80ffcc6a224e4a9e9b6ffee9b07d1911be078aaa7037fb922ab4f3 |
File details
Details for the file pytest_stochastics-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_stochastics-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.1 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 | 4b137abb3097dac0a57fb13d6235eac4f8521a28853877381094005d56e2dddf |
|
MD5 | 6bae261accf38e364471d9390761a5fc |
|
BLAKE2b-256 | 2c7b78c7c806b68dbf56097f300be18bad2607bf5681018ae5fce205c2acfd01 |