add api to iterate over all marerks of a node

This commit is contained in:
Ronny Pfannschmidt 2018-03-26 17:46:07 +02:00
parent 2cb7e725ce
commit ee51fa5881
3 changed files with 20 additions and 1 deletions

View File

@ -399,3 +399,6 @@ class NodeMarkers(object):
for mark in self.own_markers:
if mark.name == name:
yield mark
def __iter__(self):
return iter(self.own_markers)

View File

@ -1,6 +1,8 @@
from __future__ import absolute_import, division, print_function
import os
from itertools import chain
import six
import py
import attr
@ -191,9 +193,20 @@ class Node(object):
for mark in node._markers.find(name):
yield mark
def iter_markers(self):
"""
iterate over all markers of the node
"""
return chain.from_iterable(x._markers for x in reversed(self.listchain()))
def get_marker(self, name):
""" get a marker object from this node or None if
the node doesn't have a marker with that name. """
the node doesn't have a marker with that name.
..warning::
deprecated
"""
markers = list(self.find_markers(name))
if markers:
return MarkInfo(markers)

View File

@ -26,3 +26,6 @@ which also serve as documentation.
:ref:`fixtures <fixtures>`.
.. autoclass:: Mark