pytest-ordering is a pytest plugin designed to enable users to run tests in a specific, user-defined order. The latest version is 0.6, released in 2018. This project is no longer maintained, and users are strongly advised to migrate to its successor, `pytest-order`, which provides active development and additional features.
pip install pytest-orderingVerified import paths — ran on the pinned version, not inferred.
Define test execution order using the `@pytest.mark.run(order=X)` decorator. Tests with lower 'order' values run first. Tests without an explicit order may run in their natural discovery order (e.g., alphabetical or by line number) relative to each other, but after explicitly ordered tests.
Uninstall `pytest-ordering` and install `pytest-order`. Update test markers from `@pytest.mark.run(order=X)` to `@pytest.mark.order(X)`. Refer to `pytest-order` documentation for migration details.
Replace `@pytest.mark.run(order=X)` with `@pytest.mark.order(X)` in your tests.
Refactor tests to be independent and self-contained whenever possible. If ordering is strictly necessary (e.g., for integration tests with state), ensure dependencies are clearly documented and managed.
Carefully review the documentation for all installed pytest plugins, especially those affecting test collection or execution order. Test your suite thoroughly to ensure the desired order is maintained. For `pytest-xdist`, consider `--dist=loadfile` for better compatibility.