- conftest
Add extra command line parameters to Pytest - conftest - getoption
- In this case the option expects a value
- And we need to use getoption to get the value
- See Parser
- See argparse
examples/pytest/py1/conftest.py
def pytest_addoption(parser): parser.addoption("--demo") parser.addoption("--noisy", action='store_true')
examples/pytest/py1/test_one.py
def test_me(request): print(request.config.getoption("--demo")) print(request.config.getoption("--noisy"))
pytest -s None False
pytest -s --demo Hello --noisy Hello True