Skip to main content

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 out out_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 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"

Metadata

Release files for pytest-stochastics 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-stochastics 0.4.4
File Size Uploaded
pytest_stochastics-0.4.4.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-stochastics 0.4.4
File Interpreter ABI Platform
pytest_stochastics-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / pytest_stochastics-0.4.4.tar.gz

Download URL pytest_stochastics-0.4.4.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
751d7b55c9149fc5eccfdd8167db8ebff113e9f063276c560448944b2c987bb0
BLAKE2b-256 checksum
How to use checksums
048dbc0b39d833f1eec8c9f0bf95f79f67ee1431b4f38bce29b6fb33561717f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.5 Darwin/23.5.0

Release files / pytest_stochastics-0.4.4-py3-none-any.whl

Download URL pytest_stochastics-0.4.4-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d48f31d6d98e6fb5c693391291a5485ee843d9ef4a49a0b4c4fe29edc78e8760
BLAKE2b-256 checksum
How to use checksums
9cc0eaf2a1342ce1067d355c43cabb43aa55a205d39c21f84e55fdb0de9a8bb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.5 Darwin/23.5.0

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page