Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure callspecs contain the list of marks #2675

Merged
merged 1 commit into from
Aug 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions _pytest/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ def extract_from(cls, parameterset, legacy_force_tuple=False):

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

@property
def deprecated_arg_dict(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this was never part of the public API given that it is a method of the new ParameterSet class, but if I'm wrong then we should add a removal changelog note.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was a naming error, but we should add a removal message anyway

return dict((mark.name, mark) for mark in self.marks)


class MarkerError(Exception):

Expand Down
22 changes: 14 additions & 8 deletions _pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,14 +645,14 @@ def __init__(self, metafunc):
self._globalid_args = set()
self._globalparam = NOTSET
self._arg2scopenum = {} # used for sorting parametrized resources
self.keywords = {}
self.marks = []
self.indices = {}

def copy(self, metafunc):
cs = CallSpec2(self.metafunc)
cs.funcargs.update(self.funcargs)
cs.params.update(self.params)
cs.keywords.update(self.keywords)
cs.marks.extend(self.marks)
cs.indices.update(self.indices)
cs._arg2scopenum.update(self._arg2scopenum)
cs._idlist = list(self._idlist)
Expand All @@ -677,16 +677,16 @@ def getparam(self, name):
def id(self):
return "-".join(map(str, filter(None, self._idlist)))

def setmulti(self, valtypes, argnames, valset, id, keywords, scopenum,
param_index):
def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum,
param_index):
for arg, val in zip(argnames, valset):
self._checkargnotcontained(arg)
valtype_for_arg = valtypes[arg]
getattr(self, valtype_for_arg)[arg] = val
self.indices[arg] = param_index
self._arg2scopenum[arg] = scopenum
self._idlist.append(id)
self.keywords.update(keywords)
self.marks.extend(marks)

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

Expand Down Expand Up @@ -1115,7 +1115,13 @@ def __init__(self, name, parent, args=None, config=None,
self.keywords.update(self.obj.__dict__)
if callspec:
self.callspec = callspec
self.keywords.update(callspec.keywords)
# this is total hostile and a mess
# keywords are broken by design by now
# this will be redeemed later
for mark in callspec.marks:
# feel free to cry, this was broken for years before
# and keywords cant fix it per design
self.keywords[mark.name] = mark
if keywords:
self.keywords.update(keywords)

Expand Down
2 changes: 2 additions & 0 deletions changelog/2672.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Internally change ``CallSpec2`` to have a list of marks instead of a broken mapping of keywords.
This removes the keywords attribute of the internal ``CallSpec2`` class.
1 change: 1 addition & 0 deletions changelog/2675.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
remove ParameterSet.deprecated_arg_dict - its not a public api and the lack of the underscore was a naming error.
2 changes: 1 addition & 1 deletion testing/python/metafunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def func(y):
pass
metafunc = self.Metafunc(func)
metafunc.parametrize("y", [])
assert 'skip' in metafunc._calls[0].keywords
assert 'skip' == metafunc._calls[0].marks[0].name

def test_parametrize_with_userobjects(self):
def func(x, y):
Expand Down