I want to provide custom parameters on the pytest.ini file and read it from code.
[pytest]
markers =
regression: mark a test as regression.
sanity: mark a test as sanity.
critical: mark a test as critical.
addopts= -sv --html=report.html
custom_value= test
here i want to read custom_value I have tried below but it's not working and throws ValueError: no option named 'custom_value'
def test_failtest(self, request):
config = request.config
tcv = config.getoption('custom_value')
print "tcv->" + tcv
You'll need to use the pytest_addoption
hook to make the option known:
def pytest_addoption(parser):
parser.addini('custom_value', 'documentation of my custom value')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With