rework Node.add_marker parameter list and docstring

This commit is contained in:
Ronny Pfannschmidt 2018-06-12 17:50:08 +02:00
parent 9a7c3a65f4
commit b0ec442d24
2 changed files with 8 additions and 6 deletions

View File

@ -287,7 +287,11 @@ class MarkInfo(object):
def validate_marks(self, attribute, value):
for item in value:
if not isinstance(item, Mark):
raise ValueError(item)
raise ValueError(
"MarkInfo expects Mark instances, got {!r} ({!r})".format(
item, type(item)
)
)
combined = attr.ib(
repr=False,

View File

@ -173,12 +173,10 @@ class Node(object):
chain.reverse()
return chain
def add_marker(self, marker, append=True):
def add_marker(self, marker):
"""dynamically add a marker object to the node.
``marker`` can be a string or pytest.mark.* instance.
``append=True`` whether to append the marker,
if false insert at position 0
:type marker: str or pytest.mark.*
"""
from _pytest.mark import MarkDecorator, MARK_GEN