Not entirely sure if it would be considered a bug, but it surprised me. I expect iter_markers to return the markers in bottom-to-top order (outwards from the test), but for the pytestmark variable this is not the case, it returns them in the list order.
import pytest
pytestmark = [
pytest.mark.order(4),
pytest.mark.order(3),
]
@pytest.mark.order(2)
@pytest.mark.order(1)
def test_marker(request):
lowest = 0
for mark in request.node.iter_markers("order"):
order = mark.args[0]
assert order > lowest
lowest = order
FAILED test_marker.py::test_marker - assert 3 > 4
I expect this will also apply for pytestmark as a class variable.
Not entirely sure if it would be considered a bug, but it surprised me. I expect
iter_markersto return the markers in bottom-to-top order (outwards from the test), but for thepytestmarkvariable this is not the case, it returns them in the list order.I expect this will also apply for
pytestmarkas a class variable.