1

I know that there is a way to pass args in tests itself like it was shown here, but is there a way to pass in conftest.py directly? I want to configure some common stuff for all tests this way.

0

You can make something like this:

File: conftest.py

option = None

def pytest_addoption(parser):
    parser.addoption("--arg", action="store", default="example", help="Option for making some stuff")

def pytest_configure(config):
    global option
    option = config.option

and you can access your argument with option.arg in your conftest file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.