Skip to content

Commit

Permalink
fix pytest-dev#3441 - use iter-marks to populate markexpr namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed May 3, 2018
1 parent 7834b45 commit 63ef46d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
11 changes: 3 additions & 8 deletions _pytest/mark/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import attr
import keyword

from . import MarkInfo, MarkDecorator

from _pytest.config import UsageError


Expand All @@ -18,11 +16,8 @@ class MarkMapping(object):
own_mark_names = attr.ib()

@classmethod
def from_keywords(cls, keywords):
mark_names = set()
for key, value in keywords.items():
if isinstance(value, MarkInfo) or isinstance(value, MarkDecorator):
mark_names.add(key)
def from_item(cls, item):
mark_names = set(mark.name for mark in item.iter_markers())
return cls(mark_names)

def __getitem__(self, name):
Expand Down Expand Up @@ -70,7 +65,7 @@ def __getitem__(self, subname):

def matchmark(colitem, markexpr):
"""Tries to match on any marker names, attached to the given colitem."""
return eval(markexpr, {}, MarkMapping.from_keywords(colitem.keywords))
return eval(markexpr, {}, MarkMapping.from_item(colitem))


def matchkeyword(colitem, keywordexpr):
Expand Down
1 change: 1 addition & 0 deletions changelog/3441.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Also use iter_marker for discovering the marks applying for marker expressions from the cli to avoid the bad data from the legacy mark storage.

0 comments on commit 63ef46d

Please sign in to comment.