<html><head></head><body>Hi Gonzalo, <br>
<br>
Probably the pytest_generate_tests hook helps, see <a href="http://pytest.org/latest/example/parametrize.html#generating-parameters-combinations-depending-on-command-line">http://pytest.org/latest/example/parametrize.html#generating-parameters-combinations-depending-on-command-line</a><br>
<br>
Cheers holger<br><br><div class="gmail_quote">On February 7, 2016 4:53:39 AM GMT+01:00, Goncalo Morgado <goncalo.magno@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr"><div><div><div>Hi,<br /><br /></div>Thank you for this great lib!<br /><br /></div>I have an app that takes a config file with key/value pairs, that I would like to test thoroughly, i.e all possible combinations of parameters in the config file. I thought about taking advantage of the fixture parametrization functionality pytest provides, but not sure how... and end up with what I believe is a silly idea (please see example code below). I say silly because I will end up with a huge amount of <b>.mark.parametrize()</b> entries and the test case function with a number of arguments... Any idea on how to do this an elegant way?<br /><br /></div><div><b>import</b> pytest<br /></div>@pytest.mark.parametrize("key1", [0, 1, etc, etc])<br />@pytest.mark.parametrize("key2", [2, 3, etc, etc, etc])<br />@pytest.mark.parametrize("key3", [4, 5, etc, etc, etc, etc])<br />... # an infinitiy amount of @pytest.mark.parametrize("keyN", [bla
, bla,
bla])<br /><b>def</b> test_app_param_combination(key1, key2, key3, ....)<br /> # implementation of the test<br /> # run app with combination of key/value pair and check exit code<br /> <b>assert</b> app_exit_code == 0<br /><br /><div><div>Many thanks<br /></div><div>Go<br /><br /></div></div></div>
<p style="margin-top: 2.5em; margin-bottom: 1em; border-bottom: 1px solid #000"></p><pre class="k9mail"><hr /><br />pytest-dev mailing list<br />pytest-dev@python.org<br /><a href="https://mail.python.org/mailman/listinfo/pytest-dev">https://mail.python.org/mailman/listinfo/pytest-dev</a><br /></pre></blockquote></div><br>
-- <br>
Sent using mobile touch keys, increased chances for errors and misunderstandings. Enjoy! </body></html>