<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, 16 Nov 2016 at 08:00 Bruno Oliveira &lt;<a href="mailto:nicoddemus@gmail.com">nicoddemus@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Wed, Nov 16, 2016 at 10:56 AM oliver &lt;<a href="mailto:oliver.schoenborn@gmail.com" class="gmail_msg" target="_blank">oliver.schoenborn@gmail.com</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Wed, Nov 16, 2016, 00:23 Florian Bruhin &lt;<a href="mailto:me@the-compiler.org" class="gmail_msg" target="_blank">me@the-compiler.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br class="gmail_msg">
<br class="gmail_msg">
* oliver &lt;<a href="mailto:oliver.schoenborn@gmail.com" class="gmail_msg" target="_blank">oliver.schoenborn@gmail.com</a>&gt; [2016-11-16 02:32:04 +0000]:<br class="gmail_msg">
&gt; Thanks for the reply Bruno. I&#39;ve used something like that in some fixtures<br class="gmail_msg">
&gt; (actually returning a closure / lambda which, when called from the test,<br class="gmail_msg">
&gt; returns a configured object), but it seems a little counter-intuitive (the<br class="gmail_msg">
&gt; premise being that fixtures return objects ready to be used). How about<br class="gmail_msg">
&gt; overloading the item operator [], so &quot;def test(fixture[a,b])&quot; would be<br class="gmail_msg">
&gt; implemented in a similar way to annotations like &quot;Map[str, int]&quot; but<br class="gmail_msg">
&gt; fixture[a,b] would allow the fixture function to receive a, b as<br class="gmail_msg">
&gt; parameters.<br class="gmail_msg">
<br class="gmail_msg">
That&#39;s invalid Python syntax - fixture is an argument name here, not<br class="gmail_msg">
an object.<br class="gmail_msg"></blockquote></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Ah yes, rats! Then how about via a default value, this could easily be introspected by pytest: </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">def test(fixture=a): would call fixture(a) <br class="gmail_msg"></div><div class="gmail_msg">def test(fixture=[a,b]): would call fixture(a, b) <br class="gmail_msg"></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div dir="ltr" class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">Not sure if that&#39;s not abusing the syntax and confusing to some, after all `fixture=1` seems like `fixture` would be `1`, but in fact could be anything returned by the fixture.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">My opinion is that I would not be a big fan of this.</div></div></div></blockquote><div><br></div><div>If someone can understand that declaring an argument is actually going to make the argument have the return value of the function that has the name of the argument, they will certainly understand that for fixtures, the default value is the args to the fixture. And there is no ambiguity, because if the fixture is not declared it is not available to the function (an auto-fixture cannot be configured). Perhaps the non-list version is not necessary: </div><div><br></div><div># fixture will have return value of fixture(123. <span class="inbox-inbox-inbox-inbox-Apple-converted-space"> </span>&#39;some string&#39;):</div><div>def test(fixture=[123, &#39;string&#39;]): </div><div><br></div><div>Another option that would allow some autoused fixtures to be configured (scope must be compatible) would be a special pytest function. So given the following:</div><div><br></div><div><div># can be configured if desired:</div><div>@pytest.fixture(autouse=True, scope=&#39;method&#39;)<br></div><div>def autofixture(arg1=456):   </div><div>     ...</div><div><br></div><div>then </div><div><br></div><div># fixture will have return value of fixture(123. <span class="inbox-inbox-inbox-inbox-inbox-inbox-inbox-inbox-Apple-converted-space"> </span>&#39;some string&#39;), and </div><div># autofixture for this method will be side-effects of call to autofixture(456)</div><div>@pytest.config_fixtures(fixture=[123, &#39;string&#39;])</div><div>def test1(fixture): </div><div>     ...</div><br class="inbox-inbox-Apple-interchange-newline"></div><div><div># autofixture for this method will be side-effects of call to autofixture(789)</div><div>@pytest.config_fixtures(autofixture=[789])<br></div><div>def test2(): <br></div><div>     ...</div><br class="inbox-inbox-Apple-interchange-newline"></div><div>It&#39;s a bit more wordy than the default value approach, but still much better than using a marker because no boiler-plate for me to write.<span class="inbox-inbox-Apple-converted-space"> </span></div><div><span class="inbox-inbox-Apple-converted-space"><br></span></div><div><span class="inbox-inbox-Apple-converted-space">Oliver</span></div><div><span class="inbox-inbox-Apple-converted-space"><br></span></div></div></div><div dir="ltr">-- <br></div><div data-smartmail="gmail_signature"><div dir="ltr">Oliver</div></div>