{"library":"pytest-rng","title":"pytest-rng: Reproducible Randomness for Pytest Tests","description":"pytest-rng is a pytest plugin that provides fixtures to manage and inject reproducible randomness into your tests. It offers a `random.Random` instance (`rng`), a factory to create new instances (`rng_factory`), and access to the current seed (`rng_seed`). Version `1.0.0` is current, and it maintains a stable release cadence for a core pytest plugin, focusing on test stability.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install pytest-rng"],"cli":null},"imports":["def test_my_feature(rng):\n    value = rng.randint(1, 100)"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"# test_example.py\nimport os\n\ndef test_random_sequence(rng):\n    \"\"\"\n    Demonstrates using the rng fixture for reproducible randomness.\n    Run with: pytest test_example.py --rng-seed=123\n    With --rng-seed=123, rng.randint(1, 100) will consistently be 42\n    on the first call. (This is for demonstration and might vary with versions).\n    \"\"\"\n    # Use the rng fixture, which is a seeded random.Random instance\n    assert isinstance(rng.randint(1, 100), int)\n    assert isinstance(rng.random(), float)\n    # Example of running the test with a specific seed to get reproducible results:\n    # To run this specific test with a consistent seed:\n    # pytest test_example.py --rng-seed=123","lang":"python","description":"Create a test file (e.g., `test_example.py`) and define a test function that accepts the `rng` fixture. To observe reproducibility, run `pytest` with the `--rng-seed` CLI option, for instance: `pytest --rng-seed=123`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}