[pytest-dev] Fwd: Re: Proposal: python namespacign for markings/marker objects
holger krekel
holger at merlinux.eu
Thu Oct 20 03:40:06 EDT 2016
Hey Ronny,
On Thu, Oct 20, 2016 at 09:07 +0200, Ronny Pfannschmidt wrote:
> forwarding as i send it with the wrong sender address
I find it better to send a wrongly-sent mail afresh (copy+paste) than forwarding because this forwarding looses threading-info.
> > 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
> fixtures and markers are not symmetric and i don't see a reason to make
> them be
the similarity IMO would mostly be that both fixtures and markers use functions. Currently markers require non-trivial parsing code for arguments. Whereas for the above example if you have:
@pytest.mark.blocker(n=138)
it would work because "pytest.mark.blocker(...)" invokes "blocker(...)" and parsing of arguments including kw-arguments works naturally. By contrast, today you have to parse "markerinfo.kwargs" and "markerinfo.args" yourself and few plugins do it correctly.
Moreover, by forcing all marker instantiation to go through a registered function we have a single normalizing source of documentation. We can take the marker function's docstring and inspect the arguments. The current documentation for markers ("pytest --markers") is often not in sync with implementation.
holger
More information about the pytest-dev
mailing list