Reputation: 5692
I'm writing a test suite which loads tests from external (non-Python) files, in a similar manner to the YAML example in the documentation. However, I cannot work out what should be have pytest.mark.foo
called on to mark a specific item as "foo". Obviously I can't use it as a decorator as is always done in the documentation (there's no single function to decorate!), but I was assuming it would be plausible to do something similar to yield pytest.mark.foo(YamlItem(name, self, spec))
, but this does not work. Is there any way to mark such an item?
Upvotes: 0
Views: 277
Reputation: 15315
You can use Node.add_marker
function (which is a superclass of pytest.Item
):
def add_marker(self, marker):
""" dynamically add a marker object to the node.
``marker`` can be a string or pytest.mark.* instance.
"""
Upvotes: 2