allure-framework / allure-framework/allure-python

allure-pytest-bdd encounters ValueError: option names {'--alluredir'} already added

Open
#486 7 comments 0 reactions 0 assignees View on GitHub
bug theme:pytest-bdd
Dominant language
Python
Stars
814
Forks
260
PR merge metrics
No merged PRs in 30d

Description

I'm writing test cases with pytest-bdd and need allure reports with gherkin steps, but the report can't be generated properly.

**Version info**
> allure-pytest 2.8.13
allure-pytest-bdd 2.8.13
allure-python-commons 2.8.13
pytest 5.4.1
pytest-bdd 3.3.0

**pytest.ini**
> [pytest]
addopts = -vv --alluredir alluredir --clean-alluredir

Before allure-pytest-bdd is installed, test cases can run with following command line.
> pytest step_defs\test_PayInfo.py

When allure-pytest-bdd is installed, I see error msg like

> Traceback (most recent call last):
File "c:\python3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\python3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python3\Scripts\pytest.exe\__main__.py", line 7, in
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 105, in main
config = _prepareconfig(args, plugins)
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 258, in _prepareconfig
pluginmanager=pluginmanager, args=args
File "c:\python3\lib\site-packages\pluggy\hooks.py", line 289, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "c:\python3\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\python3\lib\site-packages\pluggy\manager.py", line 81, in
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "c:\python3\lib\site-packages\pluggy\callers.py", line 203, in _multicall
gen.send(outcome)
File "c:\python3\lib\site-packages\_pytest\helpconfig.py", line 90, in pytest_cmdline_parse
config = outcome.get_result()
File "c:\python3\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "c:\python3\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 836, in pytest_cmdline_parse
self.parse(args)
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 1044, in parse
self._preparse(args, addopts=addopts)
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 992, in _preparse
self.pluginmanager.load_setuptools_entrypoints("pytest11")
File "c:\python3\lib\site-packages\pluggy\manager.py", line 293, in load_setuptools_entrypoints
self.register(plugin, name=ep.name)
File "c:\python3\lib\site-packages\_pytest\config\__init__.py", line 379, in register
ret = super().register(plugin, name)
File "c:\python3\lib\site-packages\pluggy\manager.py", line 121, in register
hook._maybe_apply_history(hookimpl)
File "c:\python3\lib\site-packages\pluggy\hooks.py", line 336, in _maybe_apply_history
res = self._hookexec(self, [method], kwargs)
File "c:\python3\lib\site-packages\pluggy\manager.py", line 87, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "c:\python3\lib\site-packages\pluggy\manager.py", line 81, in
firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
File "c:\python3\lib\site-packages\pluggy\callers.py", line 208, in _multicall
return outcome.get_result()
File "c:\python3\lib\site-packages\pluggy\callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "c:\python3\lib\site-packages\pluggy\callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "c:\python3\lib\site-packages\allure_pytest_bdd\plugin.py", line 13, in pytest_addoption
help="Generate Allure report in the specified directory (may not exist)")
File "c:\python3\lib\site-packages\_pytest\config\argparsing.py", line 353, in addoption
raise ValueError("option names %s already added" % conflict)
ValueError: option names {'--alluredir'} already added

Even if I remove --alluredir alluredir, it can't be solved.

Does anyone know how to resolve it? Thank you!

Contributor guide

Open the contributing guide

Research direction

Start with allure_pytest_bdd/plugin.py at pytest_addoption, then compare how allure-pytest registers the --alluredir option. Reproduce the conflict with the versions and pytest.ini shown, including a run without --alluredir. Done means pytest starts without the duplicate-option ValueError while Allure reporting remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.