diff --git a/_pytest/mark/structures.py b/_pytest/mark/structures.py index b42a66551..3236c7828 100644 --- a/_pytest/mark/structures.py +++ b/_pytest/mark/structures.py @@ -369,13 +369,8 @@ class NodeKeywords(MappingMixin): @attr.s(cmp=False, hash=False) class NodeMarkers(object): - node = attr.ib(repr=False) own_markers = attr.ib(default=attr.Factory(list)) - @classmethod - def from_node(cls, node): - return cls(node=node) - def update(self, add_markers): """update the own markers """ @@ -386,7 +381,6 @@ class NodeMarkers(object): find markers in own nodes or parent nodes needs a better place """ - for node in reversed(self.node.listchain()): - for mark in node._markers.own_markers: - if mark.name == name: - yield mark + for mark in self.own_markers: + if mark.name == name: + yield mark diff --git a/_pytest/nodes.py b/_pytest/nodes.py index e7686b39f..bd141ae7c 100644 --- a/_pytest/nodes.py +++ b/_pytest/nodes.py @@ -90,7 +90,7 @@ class Node(object): #: keywords/markers collected from all scopes self.keywords = NodeKeywords(self) - self._markers = NodeMarkers.from_node(self) + self._markers = NodeMarkers() #: allow adding of extra keywords to use for matching self.extra_keyword_matches = set() @@ -184,7 +184,9 @@ class Node(object): def find_markers(self, name): """find all marks with the given name on the node and its parents""" - return self._markers.find(name) + for node in reversed(self.listchain()): + for mark in node._markers.find(name): + yield mark def get_marker(self, name): """ get a marker object from this node or None if