[7.4.x] fix #10447 - consider marks in reverse mro order to give base… · pytest-dev/pytest@44ad1c9 (original) (raw)

Original file line number Diff line number Diff line change
@@ -1130,6 +1130,41 @@ class C(A, B):
1130 1130
1131 1131 all_marks = get_unpacked_marks(C)
1132 1132
1133 -assert all_marks == [xfail("c").mark, xfail("a").mark, xfail("b").mark]
1133 +assert all_marks == [xfail("b").mark, xfail("a").mark, xfail("c").mark]
1134 1134
1135 1135 assert get_unpacked_marks(C, consider_mro=False) == [xfail("c").mark]
1136 +
1137 +
1138 +# @pytest.mark.issue("https://github.com/pytest-dev/pytest/issues/10447")
1139 +def test_mark_fixture_order_mro(pytester: Pytester):
1140 +"""This ensures we walk marks of the mro starting with the base classes
1141 + the action at a distance fixtures are taken as minimal example from a real project
1142 +
1143 + """
1144 +foo = pytester.makepyfile(
1145 +"""
1146 + import pytest
1147 +
1148 + @pytest.fixture
1149 + def add_attr1(request):
1150 + request.instance.attr1 = object()
1151 +
1152 +
1153 + @pytest.fixture
1154 + def add_attr2(request):
1155 + request.instance.attr2 = request.instance.attr1
1156 +
1157 +
1158 + @pytest.mark.usefixtures('add_attr1')
1159 + class Parent:
1160 + pass
1161 +
1162 +
1163 + @pytest.mark.usefixtures('add_attr2')
1164 + class TestThings(Parent):
1165 + def test_attrs(self):
1166 + assert self.attr1 == self.attr2
1167 + """
1168 + )
1169 +result = pytester.runpytest(foo)
1170 +result.assert_outcomes(passed=1)