Pytest - test case execution order

Pytest-ordering seems abandoned at the moment, you can also check out pytest-order (a fork of the original project).

import pytest

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

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

You can use pytest-ordering

See https://pytest-ordering.readthedocs.io/en/develop/

import pytest
@pytest.mark.run(order=1)
def test_first():
    pass
@pytest.mark.run(order=2)
def test_second():
    pass

test_sample.py::test_first PASSED
test_sample.py::test_second PASSED