Run pytest in order

Hi, I am checking out http://pytest-ordering.readthedocs.org/en/develop/ "to execute pytest in order

I tried the following code,

import pytest

@pytest.mark.order2
def test_foo():
    assert True

@pytest.mark.order1
def test_bar():
    assert True

But execution is performed randomly. Can someone please let me know how to fix this?

+4
source share
1 answer

I think that the person who supports the project does not have much time to support the project: the last update was 5 months ago, and the error tracker is filled with related open problems. One of them is closely related to your problem:


, run(order=N) , - . :

import pytest

@pytest.mark.run(order=3)
def test_three():
    assert True

@pytest.mark.run(order=4)
def test_four():
    assert True

@pytest.mark.run(order=2)
def test_two():
    assert True

@pytest.mark.run(order=1)
def test_one():
    assert True

:

test.py::test_one PASSED
test.py::test_two PASSED
test.py::test_three PASSED
test.py::test_four PASSED
+5

Source: https://habr.com/ru/post/1622045/


All Articles