Pytest Order Plugin

1.3.0 · active · verified Thu Apr 09

pytest-order is a pytest plugin that allows running tests in a specific, user-defined order. It integrates with pytest using markers, providing various levels of control including custom order, dependency-based ordering, and relative ordering. The current version is 1.3.0, and it maintains an active release cadence with regular updates.

Warnings

Install

Imports

Quickstart

Demonstrates basic test ordering using `@pytest.mark.order` and dependency-based ordering using `@pytest.mark.run(after='...')` and `@pytest.mark.run(before='...')`.

import pytest

@pytest.mark.order(1)
def test_first():
    assert True

@pytest.mark.order(2)
def test_second():
    assert True

@pytest.mark.run(after='test_first')
def test_dependency_on_first():
    assert True

@pytest.mark.run(before='test_second')
def test_dependency_before_second():
    assert True

# To run these tests:
# 1. Save the code as a Python file (e.g., test_ordering.py)
# 2. Run from your terminal: pytest test_ordering.py

view raw JSON →