I am trying to execute the Python Scripts and see following error message after installing pytest-xdist
C:UsersTestPycharmProjectsDemo1venvScriptspython.exe "C:Program FilesJetBrainsPyCharm Community Edition 2020.3.3pluginspython-cehelperspycharm_jb_pytest_runner.py" --path "" -- -m negative
Testing started at 3:14 PM ...
C:Program FilesJetBrainsPyCharm Community Edition 2020.3.3pluginspython-cehelperspycharm_jb_pytest_runner.py:7: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
from pkg_resources import iter_entry_points
Launching pytest with arguments -m negative in C:UsersTestPycharmProjectsDemo1
============================= test session starts =============================
platform win32 -- Python 3.11.5, pytest-8.1.1, pluggy-1.4.0 -- C:UsersTestPycharmProjectsDemo1venvScriptspython.exe
cachedir: .pytest_cache
metadata: {'Python': '3.11.5', 'Platform': 'Windows-10-10.0.22621-SP0', 'Packages': {'pytest': '8.1.1', 'pluggy': '1.4.0'}, 'Plugins': {'allure-pytest': '2.13.5', 'easy-addoption': '0.1.1', 'html': '4.1.1', 'metadata': '3.1.1', 'xdist': '3.6.1'}}
rootdir: C:UsersTestPycharmProjectsDemo1
plugins: allure-pytest-2.13.5, easy-addoption-0.1.1, html-4.1.1, metadata-3.1.1, xdist-3.6.1
collecting ...
Lesson1:None (Lesson1)
venvLibsite-packagespluggy_manager.py:168: in register
hook._maybe_apply_history(hookimpl)
venvLibsite-packagespluggy_hooks.py:569: in _maybe_apply_history
res = self._hookexec(self.name, [method], kwargs, False)
venvLibsite-packagespluggy_manager.py:119: in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
Lesson1conftest.py:29: in pytest_addoption
parser.addoption(
venvLibsite-packages_pytestconfigargparsing.py:107: in addoption
self._anonymous.addoption(*opts, **attrs)
venvLibsite-packages_pytestconfigargparsing.py:386: in addoption
raise ValueError("option names %s already added" % conflict)
E ValueError: option names {'--browser'} already added
collected 5 items / 1 error / 5 deselected / 0 selected
=================================== ERRORS ====================================
__________________________ ERROR collecting Lesson1 ___________________________
venvLibsite-packagespluggy_manager.py:168: in register
hook._maybe_apply_history(hookimpl)
venvLibsite-packagespluggy_hooks.py:569: in _maybe_apply_history
res = self._hookexec(self.name, [method], kwargs, False)
venvLibsite-packagespluggy_manager.py:119: in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
Lesson1conftest.py:29: in pytest_addoption
parser.addoption(
venvLibsite-packages_pytestconfigargparsing.py:107: in addoption
self._anonymous.addoption(*opts, **attrs)
venvLibsite-packages_pytestconfigargparsing.py:386: in addoption
raise ValueError("option names %s already added" % conflict)
E ValueError: option names {'--browser'} already added
=========================== short test summary info ===========================
ERROR Lesson1 - ValueError: option names {'--browser'} already added
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
======================= 5 deselected, 1 error in 0.92s ========================
Process finished with exit code 2
The same works fine when tested from command line even with the parallel execution
python -m pytest -m negative –browser=chrome -n=3.
Even after removing the pytest-xdist in pycharm, i still see same error.