Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with numpy arrays and pytest.mark.parametrize #213

Closed
pytestbot opened this Issue Oct 28, 2012 · 2 comments

Comments

Projects
None yet
1 participant
@pytestbot
Copy link

commented Oct 28, 2012

Originally reported by: BitBucket: astrofrog, GitHub: 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()

@pytestbot

This comment has been minimized.

Copy link
Author

commented Oct 28, 2012

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


re-allow to parametrize with values that don't support eq (closes issue213)

@pytestbot

This comment has been minimized.

Copy link
Author

commented Oct 30, 2012

Original comment by Matt Davis (BitBucket: jiffyclub, GitHub: jiffyclub):


Thanks for fixing this so quickly. Any estimate on when the 2.3.3 release will be out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.