How to nest markers inside a parent marker? #11331
-
Hi. I'm trying to come up with a solution to have more finegrained marking for my tests. import pytest
@pytest.mark.sub.pass
def test_pass():
pass
@pytest.mark.sub.fail
def test_fail():
raise Exception() I want to have a parent maker like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Currently markers don't have that feature Without a compelling concrete use cases I'm not convinced of that feature |
Beta Was this translation helpful? Give feedback.
-
Note you could DIY a thing like this as well: import pytest
class MarkerGen:
def __init__(self, parts=None):
self.parts = parts or []
def __getattr__(self, name):
return MarkerGen(self.parts + [name])
def __call__(self, *args, **kwargs):
path = ".".join(self.parts)
marker = getattr(pytest.mark, path)
return marker(*args, **kwargs)
mark = MarkerGen()
@mark.sub.passing
def test_pass():
pass
@mark.sub.failing
def test_fail():
raise Exception() Using |
Beta Was this translation helpful? Give feedback.
Currently markers don't have that feature
Without a compelling concrete use cases I'm not convinced of that feature