<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Fabian,<div>Use the new `pytestconfig` fixture.</div><div><br></div><div># --------- conftest.py</div><div><br></div><div><div>def pytest_addoption(parser):</div><div>    parser.addoption(&quot;--name&quot;, action=&quot;store&quot;, default=&quot;default name&quot;)</div><div><br></div></div><div>#  ------- test_param.py </div><div><div>import pytest</div><div><br></div><div>@pytest.fixture()</div><div>def name(pytestconfig):</div><div>    return pytestconfig.getoption(&quot;name&quot;)</div><div><br></div><div>def test_print_name(name):</div><div>        print(f&quot;\ncommand line param (name): {name}&quot;)</div><div><br></div><div># ---- test run</div></div><div><div>$ pytest -q -s --name Brian test_param.py</div><div>command line param (name): Brian</div><div>.</div><div>1 passed in 0.01 seconds</div></div><div># ---</div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 22, 2019 at 4:00 AM Fabian Cenedese &lt;<a href="mailto:Cenedese@indel.ch">Cenedese@indel.ch</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello<br>
<br>
I want to parametrize a test I have. In the test file are several<br>
test functions together with a setup/teardown pair. I now want<br>
to give the setup function a value, preferably via command line<br>
option. I have added a conftest.py that adds the option (taken<br>
from the example, with pytest_addoption). In the setup<br>
function I can get the option with pytest.config.getoption.<br>
This works. However I get the warning that pytest.config is<br>
deprecated. How can I solve this using a fixture if I can&#39;t<br>
add request as parameter to the setup function? Or is there<br>
another way to use a test with different user definable values?<br>
<br>
Thanks<br>
<br>
bye  Fabi<br>
<br>
<br>
_______________________________________________<br>
testing-in-python mailing list<br>
<a href="mailto:testing-in-python@lists.idyll.org" target="_blank">testing-in-python@lists.idyll.org</a><br>
<a href="http://lists.idyll.org/listinfo/testing-in-python" rel="noreferrer" target="_blank">http://lists.idyll.org/listinfo/testing-in-python</a><br>
</blockquote></div></div>