<p dir="ltr">On Jan 26, 2013 3:07 PM, &quot;holger krekel&quot; &lt;<a href="mailto:holger@merlinux.eu">holger@merlinux.eu</a>&gt; wrote:<br>
&gt; On Sat, Jan 26, 2013 at 14:08 +0100, Alexander Steinert wrote:<br>
&gt; &gt; @pytest.marker<br>
&gt; &gt; def verifies(request, requirement):<br>
&gt; &gt;     ....<br>
&gt; &gt;<br>
&gt; &gt; ....<br>
&gt; &gt;<br>
&gt; &gt; @verifies(&quot;Requirement 42&quot;)<br>
&gt; &gt; def test_42():<br>
&gt; &gt;     assert False<br>
&gt; &gt;<br>
&gt; &gt; ....<br>
&gt; &gt;<br>
&gt; &gt; $ py.test . --show-verifications<br>
&gt; &gt; test_42 vierifies Requirement 42<br>
&gt; &gt;<br>
&gt; &gt; By reading the fine manual I assume that this would be a feature request.<br>
&gt; &gt; What would come closest to it using the current pytest?<br>
&gt;<br>
&gt; I have an unfinished patch which allows roughly the above.  However, it&#39;s<br>
&gt; not providing &quot;request&quot; and i am not sure how you would use it above.<br>
&gt; Certainly at collection time it cannot be the &quot;request&quot; object that&#39;s used<br>
&gt; 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">&gt; In any case, here is a test taken from the unifinished patch which showcases<br>
&gt; the intended API.<br>
[...]<br>
&gt;             @pytest.mark.mymarker<br>
&gt;             def test_1():<br>
&gt;                 assert test_1.mymarker.getarg(&quot;arg1&quot;) == 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&#39;t<br>
need access to the marker from the test itself.</p>
<p dir="ltr">/Stony<br>
</p>