--- id: pytest-randomly version: "4.1.0" license: MIT license_treatment: permissive maintenance: active --- # pytest-randomly — Pytest plugin to randomly order tests and control random.seed. License: permissive · Maintenance: active · Downloads: 10.0M/mo ## What it is and what it does pytest-randomly is a pytest plugin that randomizes test execution order and manages random seeds to expose hidden test dependencies and ensure reproducible test behavior. By default, it shuffles tests at the module, class, and function levels, then resets Python's global random seed before each test to a deterministic value derived from a base seed, the test ID, and an offset. This allows tests that use random data (via factory boy, Faker, NumPy, or Model Bakery) to remain repeatable while still exercising different code paths across runs. The plugin prints the base random seed at the start of each test run, allowing developers to reproduce failures caused by test ordering or random data by passing that seed back via the `--randomly-seed` flag. It integrates with pytest-xdist for distributed testing and supports custom random generators through an entry point mechanism. Behaviors can be disabled individually with flags like `--randomly-dont-reorganize` or `--randomly-dont-reset-seed`, and the plugin can be completely disabled with `-p no:randomly`. Use it for: - Detect inter-test pollution by running tests in random order and reproducing failures with a saved seed. - Ensure factory-generated test data remains consistent across runs while varying between tests. - Verify that tests do not depend on global state or execution order from other tests. - Reproduce flaky test failures caused by random data or test ordering by rerunning with the reported seed. - Validate test quality by exposing assumptions about test isolation and data setup. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that randomly shuffles test execution order and controls the random seed for each test, helping detect hidden test dependencies and ensuring reproducible randomized test data. Yes. This is a mature, actively maintained plugin (Production/Stable status, recent release 2026-04-20) with low install friction and no security vulnerabilities. It solves a real testing problem—detecting hidden test dependencies—that can catch subtle bugs. The MIT license imposes no restrictions. Install it if you want to improve test reliability and catch ordering-dependent failures early. ## Install pip install pytest-randomly uv add pytest-randomly poetry add pytest-randomly ## Installing pytest-randomly Before you install: Low friction install with a single runtime dependency on pytest. Actively maintained with recent releases; the repository shows 719 stars and the last commit was 2026-08-13, indicating ongoing development. License in practice: MIT license is permissive, allowing use in both open-source and proprietary projects with minimal restrictions. Quickstart: pip install pytest-randomly # Then run pytest normally; the plugin auto-activates: pytest # Output shows the random seed: # Using --randomly-seed=1553614239 # Reproduce a failure with: pytest --randomly-seed=1234 Requires Python 3.10 or later. Verify before relying: - Whether the plugin works reliably with all pytest-xdist configurations and distributed test scenarios - Performance impact when running large test suites with hundreds or thousands of tests ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 10.0M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest random test order, test randomization plugin, random seed control pytest, detect test dependencies, reproducible random tests, shuffle test execution, pytest test ordering, test-quality, randomization, pytest-plugin [View on SkillFed](https://skillfed.io/packages/pytest-randomly) · [View on PyPI](https://pypi.org/project/pytest-randomly/)