Skip to content

Commit b848603

Browse files
fix #3605 - unpack markdecorators from parameterization
1 parent 78a82c0 commit b848603

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

changelog/3605.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unpack marks from parameterization to prevent the markdecorator missmatch bug.

src/_pytest/mark/structures.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,12 @@ def get_unpacked_marks(obj):
225225
obtain the unpacked marks that are stored on an object
226226
"""
227227
mark_list = getattr(obj, "pytestmark", [])
228-
229228
if not isinstance(mark_list, list):
230229
mark_list = [mark_list]
230+
return normalize_mark_list(mark_list)
231+
232+
233+
def normalize_mark_list(mark_list):
231234
return [getattr(mark, "mark", mark) for mark in mark_list] # unpack MarkDecorator
232235

233236

src/_pytest/python.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
get_default_arg_names,
4040
)
4141
from _pytest.outcomes import fail
42-
from _pytest.mark.structures import transfer_markers, get_unpacked_marks
42+
from _pytest.mark.structures import (
43+
transfer_markers,
44+
get_unpacked_marks,
45+
normalize_mark_list,
46+
)
4347

4448

4549
# relative paths that we use to filter traceback entries from appearing to the user;
@@ -773,7 +777,7 @@ def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index
773777
self.indices[arg] = param_index
774778
self._arg2scopenum[arg] = scopenum
775779
self._idlist.append(id)
776-
self.marks.extend(marks)
780+
self.marks.extend(normalize_mark_list(marks))
777781

778782
def setall(self, funcargs, id, param):
779783
for x in funcargs:
@@ -1254,7 +1258,7 @@ def __init__(
12541258
# feel free to cry, this was broken for years before
12551259
# and keywords cant fix it per design
12561260
self.keywords[mark.name] = mark
1257-
self.own_markers.extend(callspec.marks)
1261+
self.own_markers.extend(normalize_mark_list(callspec.marks))
12581262
if keywords:
12591263
self.keywords.update(keywords)
12601264

testing/test_mark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,4 +1168,4 @@ def test_custom_mark_parametrized(obj_type):
11681168
)
11691169

11701170
result = testdir.runpytest()
1171-
result.assert_outcomes(failed=0)
1171+
result.assert_outcomes(passed=4)

0 commit comments

Comments
 (0)