pytest executes tests in a randomly order. Sometimes it can be useful to have a predefined order in which test cases can run.
pytest has a neat plugin for this specific use case.
pip install pytest-order
import pytest @pytest.mark.order(1) def test_foo(): assert True @pytest.mark.order(2) def test_bar(): assert True @pytest.mark.order(3) def test_foobar(): assert True