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

This commit is contained in:
holger krekel 2012-10-28 14:52:43 +01:00
parent 573599beb3
commit fce13c3e46
3 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,9 @@
Changes between 2.3.2 and 2.3.3.dev
-----------------------------------
- fix issue213 - allow to parametrize with values like numpy arrays that
do not support an __eq__ operator
Changes between 2.3.1 and 2.3.2
-----------------------------------

View File

@ -598,7 +598,7 @@ class CallSpec2(object):
if valtype == "funcargs":
self.params[arg] = id
self._arg2scopenum[arg] = scopenum
if val == _notexists:
if val is _notexists:
self._emptyparamspecified = True
self._idlist.append(id)

View File

@ -313,6 +313,19 @@ class TestFunction:
reprec = testdir.inline_run()
reprec.assertoutcome(skipped=1)
def test_issue213_parametrize_value_no_equal(self, testdir):
testdir.makepyfile("""
import pytest
class A:
def __eq__(self, other):
raise ValueError("not possible")
@pytest.mark.parametrize('arg', [A()])
def test_function(arg):
assert arg.__class__.__name__ == "A"
""")
reprec = testdir.inline_run()
reprec.assertoutcome(passed=1)
def test_function_equality_with_callspec(self, testdir, tmpdir):
items = testdir.getitems("""
import pytest