<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/13 Wouter Overmeire <span dir="ltr">&lt;<a href="mailto:lodagro@gmail.com" target="_blank">lodagro@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>Somehow i missed the point that it is possible to access the config object trough the metafunc argument of pytest_generate_tests when i first looked at the docs. Based on your recommendations i gave it another go, problem solved. Thanks for your feedback!</div>

<div><div><div><br></div><div>There is however another problem now. There is a big difference in the order of configuration / test execution when deferring the setup of parametrized resources.</div><div>When using the params argument of the pytest.fixture decorator the tests are run such that for a given config of the platform, all tests run after each other. This is what i want, since the config is time-consuming compared to running the tests. When using the pytest_generate_tests function to parameterize the platform fixture, the tests are run, such that one give tests is executed for all configs, than the next test for all selcted configs, and so on. Is there an easy way to change the ordering? Or should i implement my own ordering, maybe using pytest_collection_modifyitems?</div>
</div></div></div></blockquote><div><br></div><div>metafunc.parametrize(...., scope=&#39;session&#39;) does the trick</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div>
<div><br></div></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/12/13 holger krekel <span dir="ltr">&lt;<a href="mailto:holger@merlinux.eu" target="_blank">holger@merlinux.eu</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Wouter,<br>
<div><br>
On Fri, Dec 13, 2013 at 12:21 +0100, Wouter Overmeire wrote:<br>
&gt; Using py.test (version 2.5.0) i would like to run a number of test on a<br>
&gt; user select-able platform with multiple configurations.  A platform is a<br>
&gt; bunch measurement instruments, and  hardware under test. The tests are not<br>
&gt; aware on which specific platform they run, nor how the platform is<br>
&gt; configured, they get a platform fixture object and do stuff with it.<br>
&gt;<br>
&gt; Using two parser arguments &quot;--platform&quot; and  &quot;--config&quot;&quot; the user can<br>
&gt; select a platform and a platform config. The platform fixture function gets<br>
&gt; the options from the request object, creates, configures and returns the<br>
&gt; platform. So far so good.<br>
<br>
</div>:)<br>
<div><br>
&gt; However, test need to run for many configs (range 100) on  a single<br>
&gt; platform, configs are grouped in sets. The user should be able to select<br>
&gt; the config set. Instead of selecting a single config i would like to select<br>
&gt; a set, the &quot;&quot;--config&quot; option is now the name (string) referring to a<br>
&gt; factory function generating a list of configs. But i`m stuck on how to<br>
&gt; parameterize the platform fixture function using the &quot;--config&quot; parser<br>
&gt; option. The fixture decorator has a &quot;parameters&quot; argument to parameterize a<br>
&gt; fixture, which can do the trick for a hardcoded config set, but how to set<br>
&gt; the values based on a parser option? I also tried to use<br>
&gt; pytest.yield_fixture, but this supports only a single yield statement :-(.<br>
<br>
</div>I recommend you look into the pytest_generate_tests hook:<br>
<br>
    <a href="http://pytest.org/latest/parametrize.html#pytest-generate-tests" target="_blank">http://pytest.org/latest/parametrize.html#pytest-generate-tests</a><br>
<br>
It allows to define actual parameters for building a fixture from<br>
the command line.  In the API description of Metafunc.parametrize()<br>
on that page you find &quot;indirect&quot;.  If you set it to true then your<br>
fixture function can access the indirect parameter via the typical<br>
&quot;request.param&quot;.  See also the following example:<br>
<br>
    <a href="http://pytest.org/latest/example/parametrize.html#deferring-the-setup-of-parametrized-resources" target="_blank">http://pytest.org/latest/example/parametrize.html#deferring-the-setup-of-parametrized-resources</a><br>


<br>
HTH,<br>
holger<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>