allure-pytest-bdd encounters ValueError: option names {'--alluredir'} already added
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, infirstresult=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!
Hi @Moonzoe You are getting above mentioned error as you have defined both: allure-pytest 2.8.13 allure-pytest-bdd 2.8.13
Use either one of them in your requirements file to generate report.
Report generated by both plugins are slightly different.
Hi @Moonzoe You are getting above mentioned error as you have defined both: allure-pytest 2.8.13 allure-pytest-bdd 2.8.13
Use either one of them in your requirements file to generate report.
Report generated by both plugins are slightly different.
Thank you @SavitaMaurya for your kindly response. If allure-pytest is removed, allure files can't be generated. allure-pytest-bdd is the one I really need though.
I happen to have the same problem. I have both unit and feature tests.
if they cannot live together, how do you think is the best way to handle both reports?
I manage to make this by having both libraries included in my requirements.txt and depending the test I call I exclude one or the other.
When running unit tests, I run:
pytest -p no:allure_pytest_bdd -m "not e2e"
When running e2e tests, I run:
pytest -p no:allure_pytest -m "e2e"
I'm kinda having the same problem by having a mixed setup of bdd tests as well as unit tests. Is there any plan to make them both work at the same time? Also, can you maybe point out the major differences between the reports by the respective plugins?
@GonzaloSaad
I manage to make this by having both libraries included in my
requirements.txtand depending the test I call I exclude one or the other.When running
unittests, I run:pytest -p no:allure_pytest_bdd -m "not e2e"When running
e2etests, I run:pytest -p no:allure_pytest -m "e2e"
Nice one! Worked in my case, by adding the -p no:allure_pytest_bdd for the UI tests and the -p no:allure_pytest the API tests
Thanks!