summaryrefslogtreecommitdiff
path: root/_pytest/main.py
diff options
context:
space:
mode:
authorholger krekel <holger@merlinux.eu>2013-10-03 15:43:56 +0200
committerholger krekel <holger@merlinux.eu>2013-10-03 15:43:56 +0200
commit2248a31a44da9c9fb4e939b6a4753609ce617a8c (patch)
tree57ab1085fe15934ff563066e2b274432f151cd9f /_pytest/main.py
parent9fdfa155fb0608cdc529608d19c01d66f412fb99 (diff)
downloadpytest-2248a31a44da9c9fb4e939b6a4753609ce617a8c.tar.gz
more fixes regarding marking, in particular plugins should use add_marker/get_marker now.
Diffstat (limited to '_pytest/main.py')
-rw-r--r--_pytest/main.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/_pytest/main.py b/_pytest/main.py
index 4cca93ff1..5d9c243ee 100644
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -321,6 +321,27 @@ class Node(object):
chain.reverse()
return chain
+ def add_marker(self, marker):
+ """ dynamically add a marker object to the node.
+
+ ``marker`` can be a string or pytest.mark.* instance.
+ """
+ from _pytest.mark import MarkDecorator
+ if isinstance(marker, py.builtin._basestring):
+ marker = MarkDecorator(marker)
+ elif not isinstance(marker, MarkDecorator):
+ raise ValueError("is not a string or pytest.mark.* Marker")
+ self.keywords[marker.name] = marker
+
+ 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. """
+ val = self.keywords.get(name, None)
+ if val is not None:
+ from _pytest.mark import MarkInfo, MarkDecorator
+ if isinstance(val, (MarkDecorator, MarkInfo)):
+ return val
+
def listextrakeywords(self):
""" Return a set of all extra keywords in self and any parents."""
extra_keywords = set()