Skip to content

AssertionError with wrong number of parametrize arguments #2383

@The-Compiler

Description

@The-Compiler

This:

import pytest

@pytest.mark.parametrize('foo, bar', [(1, 2, 3)])
def test_foo(foo, bar):
    pass

gives us:

../proj/pytest/_pytest/runner.py:157: in __init__
    self.result = func()
../proj/pytest/_pytest/runner.py:328: in <lambda>
    lambda: list(collector.collect()),
../proj/pytest/_pytest/python.py:402: in collect
    return super(Module, self).collect()
../proj/pytest/_pytest/python.py:314: in collect
    res = self.makeitem(name, obj)
../proj/pytest/_pytest/python.py:326: in makeitem
    collector=self, name=name, obj=obj)
../proj/pytest/_pytest/vendored_packages/pluggy.py:745: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../proj/pytest/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../proj/pytest/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../proj/pytest/_pytest/vendored_packages/pluggy.py:613: in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
../proj/pytest/_pytest/vendored_packages/pluggy.py:250: in _wrapped_call
    wrap_controller.send(call_outcome)
../proj/pytest/_pytest/python.py:185: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
../proj/pytest/_pytest/python.py:346: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
../proj/pytest/_pytest/vendored_packages/pluggy.py:745: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../proj/pytest/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../proj/pytest/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../proj/pytest/_pytest/vendored_packages/pluggy.py:614: in execute
    res = hook_impl.function(*args)
../proj/pytest/_pytest/python.py:112: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
../proj/pytest/_pytest/python.py:846: in parametrize
    assert len(param.values) == len(argnames)
E   AssertionError

it'd be nice to show a proper error message instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueeasy issue that is friendly to new contributortopic: collectionrelated to the collection phasetopic: parametrizerelated to @pytest.mark.parametrize

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions