Is there a way in PyTest to pass command line arguments to conftest.py directly?
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.
You can make something like this:
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.argin your conftest file.