Skip to content

main: args must be a list, not tuple#6791

Merged
blueyed merged 1 commit intopytest-dev:masterfrom
blueyed:main-no-tuple
Feb 22, 2020
Merged

main: args must be a list, not tuple#6791
blueyed merged 1 commit intopytest-dev:masterfrom
blueyed:main-no-tuple

Conversation

@blueyed
Copy link
Contributor

@blueyed blueyed commented Feb 21, 2020

Passing in a tuple crashes in _prepareconfig:

    def test_invoke_with_tuple(self):
>       pytest.main(("-h",))

src/_pytest/config/__init__.py:82: in main
    config = _prepareconfig(args, plugins)
src/_pytest/config/__init__.py:229: in _prepareconfig
    return pluginmanager.hook.pytest_cmdline_parse(
…
src/_pytest/helpconfig.py:98: in pytest_cmdline_parse
    config = outcome.get_result()  # type: Config
src/_pytest/config/__init__.py:808: in pytest_cmdline_parse
    self.parse(args)
src/_pytest/config/__init__.py:1017: in parse
    self._preparse(args, addopts=addopts)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def _preparse(self, args: List[str], addopts: bool = True) -> None:
        …
        if addopts:
            ini_addopts = self.getini("addopts")
            if ini_addopts:
>               args[:] = self._validate_args(ini_addopts, "via addopts config") + args
E               TypeError: can only concatenate list (not "tuple") to list

addopts    = True
args       = ('-h',)
env_addopts = ''
ini_addopts = ['-rfEX', …]

src/_pytest/config/__init__.py:956: TypeError: can only concatenate list (not "tuple") to list

Might be worth handling (converting it to a list for example), but it
was documented to be a list to begin with when removing support for
strings (a7e4016).

Passing in a tuple crashes in `_prepareconfig`:

        def test_invoke_with_tuple(self):
    >       pytest.main(("-h",))

    src/_pytest/config/__init__.py:82: in main
        config = _prepareconfig(args, plugins)
    src/_pytest/config/__init__.py:229: in _prepareconfig
        return pluginmanager.hook.pytest_cmdline_parse(
    …
    src/_pytest/helpconfig.py:98: in pytest_cmdline_parse
        config = outcome.get_result()  # type: Config
    src/_pytest/config/__init__.py:808: in pytest_cmdline_parse
        self.parse(args)
    src/_pytest/config/__init__.py:1017: in parse
        self._preparse(args, addopts=addopts)
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

        def _preparse(self, args: List[str], addopts: bool = True) -> None:
            …
            if addopts:
                ini_addopts = self.getini("addopts")
                if ini_addopts:
    >               args[:] = self._validate_args(ini_addopts, "via addopts config") + args
    E               TypeError: can only concatenate list (not "tuple") to list

    addopts    = True
    args       = ('-h',)
    env_addopts = ''
    ini_addopts = ['-rfEX', …]

    src/_pytest/config/__init__.py:956: TypeError: can only concatenate list (not "tuple") to list

Might be worth handling (converting it to a list for example), but it
was documented to be a list to begin with when removing support for
strings (a7e4016).
@blueyed blueyed merged commit 478a244 into pytest-dev:master Feb 22, 2020
@blueyed blueyed deleted the main-no-tuple branch February 22, 2020 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants