Using pytest_addoption() via list of options. If list contains less then 2 items - we'll get an error option names {'--a'} already added.
option_list = (
'test_attribute'
)
def pytest_addoption(parser):
parser.addoption('--env', action='store', default=None)
for option in option_list:
parser.addoption(f'--{option}', action='store', default=None)
ValueError: option names {'--a'} already added
option_list = (
'test_attribute_1',
'test_attribute_2'
)
My environment
$ pip list
Package Version
--------------------- -------
allure-pytest 2.3.2b1
allure-python-commons 2.3.2b1
pip 20.2.4
PyHamcrest 1.9.0
pytest 3.4.0
PyYAML 5.3.1
$ sw_vers
ProductName: macOS
ProductVersion: 11.0.1
BuildVersion: 20B50
pip list from the virtual environment you are usingUser error, the constant is a string not a list/tuple
@pashkatrick as Ronny mentions, this is a user error, as brackets do not necessarily denote a tuple:
In [21]: type('one')
Out[21]: str
in your case, option_list = ('test_attribute',) is correct.
Most helpful comment
@pashkatrick as Ronny mentions, this is a user error, as brackets do not necessarily denote a tuple:
in your case,
option_list = ('test_attribute',)is correct.