Skip to content

Commit eb46258

Browse files
fix #2675 - store marks correctly in callspecs
1 parent 9e62a31 commit eb46258

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

_pytest/mark.py

-4
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ def extract_from(cls, parameterset, legacy_force_tuple=False):
6767

6868
return cls(argval, marks=newmarks, id=None)
6969

70-
@property
71-
def deprecated_arg_dict(self):
72-
return dict((mark.name, mark) for mark in self.marks)
73-
7470

7571
class MarkerError(Exception):
7672

_pytest/python.py

+14-8
Original file line numberDiff line numberDiff line change
@@ -645,14 +645,14 @@ def __init__(self, metafunc):
645645
self._globalid_args = set()
646646
self._globalparam = NOTSET
647647
self._arg2scopenum = {} # used for sorting parametrized resources
648-
self.keywords = {}
648+
self.marks = []
649649
self.indices = {}
650650

651651
def copy(self, metafunc):
652652
cs = CallSpec2(self.metafunc)
653653
cs.funcargs.update(self.funcargs)
654654
cs.params.update(self.params)
655-
cs.keywords.update(self.keywords)
655+
cs.marks.extend(self.marks)
656656
cs.indices.update(self.indices)
657657
cs._arg2scopenum.update(self._arg2scopenum)
658658
cs._idlist = list(self._idlist)
@@ -677,16 +677,16 @@ def getparam(self, name):
677677
def id(self):
678678
return "-".join(map(str, filter(None, self._idlist)))
679679

680-
def setmulti(self, valtypes, argnames, valset, id, keywords, scopenum,
681-
param_index):
680+
def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum,
681+
param_index):
682682
for arg, val in zip(argnames, valset):
683683
self._checkargnotcontained(arg)
684684
valtype_for_arg = valtypes[arg]
685685
getattr(self, valtype_for_arg)[arg] = val
686686
self.indices[arg] = param_index
687687
self._arg2scopenum[arg] = scopenum
688688
self._idlist.append(id)
689-
self.keywords.update(keywords)
689+
self.marks.extend(marks)
690690

691691
def setall(self, funcargs, id, param):
692692
for x in funcargs:
@@ -842,8 +842,8 @@ def parametrize(self, argnames, argvalues, indirect=False, ids=None,
842842
'equal to the number of names ({1})'.format(
843843
param.values, argnames))
844844
newcallspec = callspec.copy(self)
845-
newcallspec.setmulti(valtypes, argnames, param.values, a_id,
846-
param.deprecated_arg_dict, scopenum, param_index)
845+
newcallspec.setmulti2(valtypes, argnames, param.values, a_id,
846+
param.marks, scopenum, param_index)
847847
newcalls.append(newcallspec)
848848
self._calls = newcalls
849849

@@ -1115,7 +1115,13 @@ def __init__(self, name, parent, args=None, config=None,
11151115
self.keywords.update(self.obj.__dict__)
11161116
if callspec:
11171117
self.callspec = callspec
1118-
self.keywords.update(callspec.keywords)
1118+
# this is total hostile and a mess
1119+
# keywords are broken by design by now
1120+
# this will be redeemed later
1121+
for mark in callspec.marks:
1122+
# feel free to cry, this was broken for years before
1123+
# and keywords cant fix it per design
1124+
self.keywords[mark.name] = mark
11191125
if keywords:
11201126
self.keywords.update(keywords)
11211127

changelog/2672.removal

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Internally change ``CallSpec2`` to have a list of marks instead of a broken mapping of keywords.
2+
This removes the keywords attribute of the internal ``CallSpec2`` class.

changelog/2675.removal

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
remove ParameterSet.deprecated_arg_dict - its not a public api and the lack of the underscore was a naming error.

testing/python/metafunc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def func(y):
158158
pass
159159
metafunc = self.Metafunc(func)
160160
metafunc.parametrize("y", [])
161-
assert 'skip' in metafunc._calls[0].keywords
161+
assert 'skip' == metafunc._calls[0].marks[0].name
162162

163163
def test_parametrize_with_userobjects(self):
164164
def func(x, y):

0 commit comments

Comments
 (0)