[py-dev] [hpk42/pytest] Issue with numpy arrays and pytest.mark.parametrize (issue #213)

astrofrog issues-reply at bitbucket.org
Sun Oct 28 13:19:26 CET 2012


--- you can reply above this line ---

New issue 213: Issue with numpy arrays and pytest.mark.parametrize
https://bitbucket.org/hpk42/pytest/issue/213/issue-with-numpy-arrays-and

astrofrog:

The following tests used to pass:

```
import pytest
import numpy as np

@pytest.mark.parametrize(('error'), [1., 'spam', np.ones((5, 5))])
def test(error):
    pass
```

but in the latest tip (5de7185c2891) I get the following exception:

```
_________________________________________________ ERROR collecting astropy/nddata/tests/test_nddata.py _________________________________________________
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/runner.py:121: in __init__
>               self.result = func()
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/main.py:366: in _memocollect
>       return self._memoizedcall('_collected', lambda: list(self.collect()))
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/main.py:287: in _memoizedcall
>           res = function()
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/main.py:366: in <lambda>
>   return self._memoizedcall('_collected', lambda: list(self.collect()))
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:348: in collect
>       return super(Module, self).collect()
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:281: in collect
>                   res = self.makeitem(name, obj)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:293: in makeitem
>           collector=self, name=name, obj=obj)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/main.py:157: in call_matching_hooks
>       return hookmethod.pcall(plugins, **kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:426: in pcall
>       return self._docall(methods, kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:433: in _docall
>           res = mc.execute()
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:351: in execute
>           res = method(**kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:185: in pytest_pycollect_makeitem
>               return list(collector._genfunctions(name, obj))
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:309: in _genfunctions
>       gentesthook.pcall(plugins, metafunc=metafunc)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:426: in pcall
>       return self._docall(methods, kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:433: in _docall
>           res = mc.execute()
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/core.py:351: in execute
>           res = method(**kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:105: in pytest_generate_tests
>           metafunc.parametrize(*marker.args, **marker.kwargs)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:687: in parametrize
>                                    scopenum)
/Users/tom/Library/Python/2.7/lib/python/site-packages/pytest-2.3.2-py2.7.egg/_pytest/python.py:601: in setmulti
>           if val == _notexists:
E           ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```


--

This is an issue notification from bitbucket.org. You are receiving
this either because you are the owner of the issue, or you are
following the issue.



More information about the Pytest-dev mailing list