On 7 September 2016 at 10:38, Ronny Pfannschmidt <rpfan...@redhat.com> wrote: > Hi all, > > while trying to turn various internal markers of a work project > into public plugins, i noticed a very plain problems - different other > plugins used the same generic marker name for different purposes/intents > > such a flat namespace really doesn't scale > > as such i would like to propose having marker types and objects as > importable objects > > for example > > import pytest > from pytest_bugzilla import Blocker > > @pytest.mark(Blocker(123)) > def test_fun(): > pass > > that way we can do both, reuse python name-spacing *and* use more meaningful > objects for markings
I'm rather lukewarm for this proposal to be honest. We already have an API which allows creating of mark objects for later re-use: blocker = pytest.mark.bugzilla_blocker @blocker def test_fun(): pass So instead of changing the way way pytest.mark behaves I think it might be more interesting to look at alternative ways of creating marker objects. E.g. if you could do: # pytest_bugzilla.py class Blocker(pytest.MarkerObject): def __init__(self, n): pass # test_fun.py from pytest_bugzilla import Blocker @Blocker(123) def test_fun(): pass Then you can still import your marker and you also get more strict namespacing since you created a unique object in your module. But the benefit is that from the point of view of using markers not much has changed. There's just a new way of creating markers. What do you reckon about such an approach? Finally, and I only just remembered, Holger has some lingering code somewhere which does something like: @pytest.marker def blocker(n): return {'issue no': int(n)} # or whatever object you want your marker to be @pytest.mark.blocker(123) def test_fun(): pass This uses symmetry with how we create fixtures, which is nice. But it does not solve the namespacing issue, which to some extend also exists in fixtures. Just brainstorming to add something namespace like to that would be: @pytest.marker(ns='bugzilla') def blocker(n): return int(n) @pytest.mark.bugzilla.blocker(123) def test_fun(): pass I admit this does not re-use the python module namespaces, which is probably a downside. Floris _______________________________________________ pytest-dev mailing list pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev