[pytest-dev] Proposal: python namespacign for markings/marker objects

Ronny Pfannschmidt opensource at ronnypfannschmidt.de
Thu Oct 20 05:12:10 EDT 2016

Hi Holger,

On 20.10.2016 10:56, holger krekel wrote:
> Hey Ronny,
> i'd like to get back to your original suggestion ...
> On Wed, Sep 07, 2016 at 11:38 +0200, Ronny Pfannschmidt 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
> The more plugins there are the more it causes potential clashes of marker and fixture names.  We've had some discussions at the sprint about it IIRC.  I suggest that whatever namespacing we come up with it should be a) backward-compatible b) work for both markers and fixtures.
python packages are pretty perfect for name-spacing markers, and its
backward compatible

as for fixture namespaces, if we base them in plain string names and
continue doing so,
i feel absolutely certain it will break in a messy way and it has
different referencing needs than markers

so making 2 different things use the same mechanism is a guarantee that
we end up in a broken mess :(

i'd much rather start a discussion about using different means even for
but thats for a different topic that i hope to start this weekend (and
it would solve  lot of massive headaches wrt getting rid of py.path.local)

>> 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
> a few questions:
> - How would you integrate this with interactive help such as "py.test --markers"? 
i see 2 sensible paths
a) a new entry-point to make them discover-able
b) running collection and getting a set of the used marker names

> - how would you access the Blocker marker from a hook?  New API?
   basically a mark name is either a identifier or a type

    getmarker(Blocker) ->mark collection of Blocker objects
   this api break is needed anyway because what we have now is
demonstrably broken and unusable
   in various situations, usage and parameters we get different kinds of
objects with different behaviors
> - how would you apply it at module or class level?
pytestmark = [ Blocker(123) ]

> holger
> _______________________________________________
> pytest-dev mailing list
> pytest-dev at python.org
> https://mail.python.org/mailman/listinfo/pytest-dev
-- Ronny

More information about the pytest-dev mailing list