Skip to content

pytest.mark.parametrize over None and empty dict #5775

@andreacassioli

Description

@andreacassioli

I am trying to run tests like the following

@pytest.mark.parametrize('y,shipment', [None])
@pytest.mark.parametrize('x', [None])
def test_foo(x, y):
    #whatever

I get a very criptic long error as follow

---------------------------------------------------------------------------------------------------------------------------------------------- generated xml file: /Users/aca286/workspace/protomorph/tests.xml ----------------------------------------------------------------------------------------------------------------------------------------------------
================================================================================================================================================================================= ERRORS =================================================================================================================================================================================
________________________________________________________________________________________________________________________________________________________ ERROR collecting app/tests/data/test_cost_calculation.py ________________________________________________________________________________________________________________________________________________________
../../anaconda3/lib/python3.6/site-packages/_pytest/runner.py:196: in __init__
    self.result = func()
../../anaconda3/lib/python3.6/site-packages/_pytest/runner.py:375: in <lambda>
    lambda: list(collector.collect()),
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:389: in collect
    return super(Module, self).collect()
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:330: in collect
    res = self.makeitem(name, obj)
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:342: in makeitem
    collector=self, name=name, obj=obj)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:745: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:613: in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:250: in _wrapped_call
    wrap_controller.send(call_outcome)
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:188: in pytest_pycollect_makeitem
    res = list(collector._genfunctions(name, obj))
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:362: in _genfunctions
    self.ihook.pytest_generate_tests(metafunc=metafunc)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:745: in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:339: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:334: in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
../../anaconda3/lib/python3.6/site-packages/_pytest/vendored_packages/pluggy.py:614: in execute
    res = hook_impl.function(*args)
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:113: in pytest_generate_tests
    metafunc.parametrize(*marker.args, **marker.kwargs)
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:833: in parametrize
    ids = idmaker(argnames, parameters, idfn, ids, self.config)
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:958: in idmaker
    for valindex, parameterset in enumerate(parametersets)]
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:958: in <listcomp>
    for valindex, parameterset in enumerate(parametersets)]
../../anaconda3/lib/python3.6/site-packages/_pytest/python.py:950: in _idvalset
    for val, argname in zip(parameterset.values, argnames)]
E   TypeError: zip argument #1 must support iteration```

I am running on

11:27 $ python
Python 3.6.3 | packaged by conda-forge | (default, Nov  4 2017, 10:13:32) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 

and

pytest==3.2.1
pytest-cov==2.6.0

what am I missing?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: needs informationreporter needs to provide more information; can be closed after 2 or more weeks of inactivitytopic: parametrizerelated to @pytest.mark.parametrizetype: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions