From fce13c3e465ec127cd70b104bc647b74dcd7cd9d Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sun, 28 Oct 2012 14:52:43 +0100 Subject: [PATCH] re-allow to parametrize with values that don't support __eq__ (closes issue213) --- CHANGELOG | 6 ++++++ _pytest/python.py | 2 +- testing/test_python.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 354c70013..64710f659 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 ----------------------------------- diff --git a/_pytest/python.py b/_pytest/python.py index cad2d37ef..3a28f7771 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -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) diff --git a/testing/test_python.py b/testing/test_python.py index 78b5484c0..77c206f4c 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -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