Skip to main content

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

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

pytest_stochastics-0.4.2.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_stochastics-0.4.2-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_stochastics-0.4.2.tar.gz.

File metadata

  • Download URL: pytest_stochastics-0.4.2.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

Hashes for pytest_stochastics-0.4.2.tar.gz
Algorithm Hash digest
SHA256 873ad399ede7222aaaea5518372c20a6627e73f032a370b5fd1fdec965b245d7
MD5 8f9e720047aeaf1f004bba865eb24aee
BLAKE2b-256 81c197169003b276ff9fb2fea486da1085120f013bbf1e682cd818e9fb159676

See more details on using hashes here.

File details

Details for the file pytest_stochastics-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: pytest_stochastics-0.4.2-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

Hashes for pytest_stochastics-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f36f4f8d83ac9a3748c2ceaa7ce14fd4842ced5bb5c230a81b2035d0f02dae5
MD5 9b8dd85f8523f93b35eb66391c11bcb5
BLAKE2b-256 3b6bbac2c3e9948f92cb4c10d21315fcfb5599e033a4afbc3e2db676cbbfe9ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page