pytest-rng
Fixtures for seeding tests and making randomness reproducible
Decision gist · record as of 2026-08-14
Yes, if your test suite targets Python 3.5–3.7 and pytest versions from around 2019. The low install friction and permissive license make adoption straightforward. However, if you need modern Python versions or recent pytest support, verify compatibility first or seek an actively maintained alternative, since this package is abandoned.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires numpy and pytest as runtime dependencies; requires Python >=3.5.
- Low install friction with a pure-Python wheel.
- However, the package is abandoned—last release was August 8, 2019.
License · maintenance · safety
MIT license (permissive) — MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
last release 2019-08-08 (2563 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 156,336 downloads/mo, #10,786 on PyPI
Alternatives
Verify before relying
pip install pytest-rng
# In your test file:
import numpy as np
def test_example(rng, seed):
random_values = rng.uniform(-1, 1, size=3)
print(random_values) # Same output every run- Compatibility with pytest versions released after August 2019 and Python 3.8+
- Whether the numpy.random.mtrand.RandomState interface remains stable in current numpy versions
- Active maintenance or community forks addressing modern test framework changes
What it is and what it does
pytest-rng is a pytest plugin that provides two fixtures—`rng` and `seed`—to make random number generation deterministic and reproducible in tests. The `rng` fixture returns a pre-seeded NumPy RandomState object, while the `seed` fixture provides an integer seed value. Both derive their seeds by hashing the test's node ID combined with an optional salt string, ensuring the same random sequence runs every time unless you explicitly change the salt to test robustness across different seeds.
The package depends on numpy and pytest. It was released once on August 8, 2019 and has not been updated since, making it a stable but unmaintained tool. It is most useful for test suites that need reproducible randomness—such as machine learning or numerical computing tests—where you want to verify that random variations don't mask real bugs, yet still want to change seeds periodically to catch seed-dependent failures.
Use it for
- Ensure machine learning model tests produce identical results across runs for CI/CD pipelines
- Test numerical algorithms with reproducible random inputs while rotating seeds to catch fragile tests
- Verify stochastic simulations behave consistently without hardcoding seed values in test code
- Generate deterministic test data from random distributions without manual seed management
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if your test suite targets Python 3.5–3.7 and pytest versions from around 2019.
The low install friction and permissive license make adoption straightforward. However, if you need modern Python versions or recent pytest support, verify compatibility first or seek an actively maintained alternative, since this package is abandoned.
Install
pytest-rng on PyPI
Before you install
Low install friction with a pure-Python wheel. However, the package is abandoned—last release was August 8, 2019. No recent maintenance or updates, so compatibility with modern pytest or Python versions is unverified.
Requires numpy and pytest as runtime dependencies; requires Python >=3.5.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install pytest-rng
# In your test file:
import numpy as np
def test_example(rng, seed):
random_values = rng.uniform(-1, 1, size=3)
print(random_values) # Same output every run
Verify before relying
- Compatibility with pytest versions released after August 2019 and Python 3.8+
- Whether the numpy.random.mtrand.RandomState interface remains stable in current numpy versions
- Active maintenance or community forks addressing modern test framework changes
Package facts
| License | MIT license permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesnumpypytest |
| Maintenance | Abandoned 2,563 days since the last release |
| First released | |
| Downloads | 156,336 / month, #10,786 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableFramework :: PytestLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7 |
Evidence: pytest_rng-1.0.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest random seed fixture”
- pytest-rngProvides pytest fixtures that make random number generation…
- pytest-randomlyA pytest plugin that randomly shuffles test execution order and…
- pytest-random-orderA pytest plugin that randomizes the order in which tests run, helping…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-randomly · pytorch-seed · random-address · random2 · pyudorandom · pytest-replay · pytest-random-order · pytest-postgresql · pytest-redis · pytest-freezer