<p dir="ltr">On Jan 26, 2013 3:07 PM, "holger krekel" <<a href="mailto:holger@merlinux.eu">holger@merlinux.eu</a>> wrote:<br>
> On Sat, Jan 26, 2013 at 14:08 +0100, Alexander Steinert wrote:<br>
> > @pytest.marker<br>
> > def verifies(request, requirement):<br>
> > ....<br>
> ><br>
> > ....<br>
> ><br>
> > @verifies("Requirement 42")<br>
> > def test_42():<br>
> > assert False<br>
> ><br>
> > ....<br>
> ><br>
> > $ py.test . --show-verifications<br>
> > test_42 vierifies Requirement 42<br>
> ><br>
> > By reading the fine manual I assume that this would be a feature request.<br>
> > What would come closest to it using the current pytest?<br>
><br>
> I have an unfinished patch which allows roughly the above. However, it's<br>
> not providing "request" and i am not sure how you would use it above.<br>
> Certainly at collection time it cannot be the "request" object that's used<br>
> during fixture setup.</p>
<p dir="ltr">I see. I need some object to collect which test verifies which<br>
requirement. That could be done without pytest help using a module level<br>
dict in my conftest.py. But I think that the marker decorated by<br>
pytest.marker (or pytest.markdefinition) would benefit from getting the<br>
marked test function (or something else) as its first argument so that<br>
it can get/derive the test name unique to the test session.</p>
<p dir="ltr">Does pytest provide a hook just after collection took place? There I<br>
could evaluate my --show-verifications option, show my output and exit<br>
pytest.</p>
<p dir="ltr">> In any case, here is a test taken from the unifinished patch which showcases<br>
> the intended API.<br>
[...]<br>
> @pytest.mark.mymarker<br>
> def test_1():<br>
> assert test_1.mymarker.getarg("arg1") == 42</p>
<p dir="ltr">What about test_1.mymarker.pargs and test_1.mymarker.kwargs, in case<br>
they should be forwarded somewhere? Anyway, for my use case, I wouldn't<br>
need access to the marker from the test itself.</p>
<p dir="ltr">/Stony<br>
</p>