def add_marks(*args): def _(f): for mark in args: f = getattr(pytest.mark, mark)(f) # f = pytest.Mark(mark)(f) ? return f return _ @add_marks("A", "B", "C", "D", "E") def test_foo(): ...