From bee75437169bc16b5ac9e48954144bd227b8dd9f Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 30 Sep 2012 22:17:33 +0200 Subject: [PATCH] move Item.applymarker to Node, and defer to it from Funcargrequest.applymarker --- _pytest/main.py | 25 ++++++++++++------------- _pytest/python.py | 4 +--- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/_pytest/main.py b/_pytest/main.py index 002dc59a7..ccd8c058e 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -196,6 +196,18 @@ class Node(object): """ dictionary of Keywords / markers on this node. """ return vars(self.markers) + def applymarker(self, marker): + """ Apply a marker to this item. This method is + useful if you have several parametrized function + and want to mark a single one of them. + + :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object + created by a call to ``py.test.mark.NAME(...)``. + """ + if not isinstance(marker, pytest.mark.XYZ.__class__): + raise ValueError("%r is not a py.test.mark.* object") + setattr(self.markers, marker.markname, marker) + #def extrainit(self): # """"extra initialization after Node is initialized. Implemented # by some subclasses. """ @@ -390,19 +402,6 @@ class Item(Node): def reportinfo(self): return self.fspath, None, "" - def applymarker(self, marker): - """ Apply a marker to this item. This method is - useful if you have several parametrized function - and want to mark a single one of them. - - :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object - created by a call to ``py.test.mark.NAME(...)``. - """ - if not isinstance(marker, pytest.mark.XYZ.__class__): - raise ValueError("%r is not a py.test.mark.* object") - self.keywords[marker.markname] = marker - - @property def location(self): try: diff --git a/_pytest/python.py b/_pytest/python.py index bd453933b..7f6080c45 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -1068,9 +1068,7 @@ class FuncargRequest: :arg marker: a :py:class:`_pytest.mark.MarkDecorator` object created by a call to ``py.test.mark.NAME(...)``. """ - if not isinstance(marker, py.test.mark.XYZ.__class__): - raise ValueError("%r is not a py.test.mark.* object") - setattr(self.node.markers, marker.markname, marker) + self.node.applymarker(marker) def raiseerror(self, msg): """ raise a FuncargLookupError with the given message. """