[TIP] User defined pytest parameter in setup

Fabian Cenedese Cenedese at indel.ch
Fri Mar 22 03:57:16 PDT 2019


Hello

I want to parametrize a test I have. In the test file are several
test functions together with a setup/teardown pair. I now want
to give the setup function a value, preferably via command line
option. I have added a conftest.py that adds the option (taken
from the example, with pytest_addoption). In the setup
function I can get the option with pytest.config.getoption.
This works. However I get the warning that pytest.config is
deprecated. How can I solve this using a fixture if I can't
add request as parameter to the setup function? Or is there
another way to use a test with different user definable values?

Thanks

bye  Fabi




More information about the testing-in-python mailing list