- conftest
Add extra command line parameters to Pytest - as a fixture
- We can also create a fixture that will read the parameter
examples/pytest/py2/conftest.py
import pytest def pytest_addoption(parser): parser.addoption("--demo") @pytest.fixture def mydemo(request): return request.config.getoption("--demo")
examples/pytest/py2/test_one.py
def test_me(mydemo): print(mydemo)
pytest -s test_one.py None
pytest -s --demo Hello test_one.py Hello