microsoft / microsoft/playwright-pytest

[BUG]: pytest-playwright-asyncio introduces a duplicate option name

Open
#295 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
563
Forks
90
Avg merge
11m
Merged PRs (30d)
1

Description

When trying to use [pytest-playwright-asyncio](https://pypi.org/project/pytest-playwright-asyncio/), a ValueError is raised due to a duplicate option name:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\...\.venv\Lib\site-packages\pytest\__main__.py", line 9, in <module>
    raise SystemExit(pytest.console_main())
                     ^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 201, in console_main
    code = main()
           ^^^^^^
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 156, in main
    config = _prepareconfig(args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 342, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_hooks.py", line 512, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_callers.py", line 167, in _multicall
    raise exception
  File "C:\...\.venv\Lib\site-packages\pluggy\_callers.py", line 139, in _multicall
    teardown.throw(exception)
  File "C:\...\.venv\Lib\site-packages\_pytest\helpconfig.py", line 112, in pytest_cmdline_parse
    config = yield
             ^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_callers.py", line 121, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 1146, in pytest_cmdline_parse
    self.parse(args)
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 1527, in parse
    self._preparse(args, addopts=addopts)
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 1412, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "C:\...\.venv\Lib\site-packages\pluggy\_manager.py", line 417, in load_setuptools_entrypoints
    self.register(plugin, name=ep.name)
  File "C:\...\.venv\Lib\site-packages\_pytest\config\__init__.py", line 503, in register
    plugin_name = super().register(plugin, name)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_manager.py", line 169, in register
    hook._maybe_apply_history(hookimpl)
  File "C:\...\.venv\Lib\site-packages\pluggy\_hooks.py", line 580, in _maybe_apply_history
    res = self._hookexec(self.name, [method], kwargs, False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_manager.py", line 120, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\.venv\Lib\site-packages\pluggy\_callers.py", line 167, in _multicall
    raise exception
  File "C:\...\.venv\Lib\site-packages\pluggy\_callers.py", line 121, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\...\.venv\Lib\site-packages\pytest_playwright_asyncio\pytest_playwright.py", line 425, in pytest_addoption
    group.addoption(
  File "C:\...\.venv\Lib\site-packages\_pytest\config\argparsing.py", line 405, in addoption
    raise ValueError(f"option names {conflict} already added")
ValueError: option names {'--browser'} already added

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pytest_playwright_asyncio/pytest_playwright.py at pytest_addoption around line 425, where the --browser option is registered. Reproduce the conflict while loading pytest-playwright-asyncio and inspect how the existing plugin options are added. Done means pytest can start without the duplicate-option ValueError.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.