holger krekel avatar holger krekel committed 239a300

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

Comments (0)

Files changed (3)

+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
 -----------------------------------
 

_pytest/python.py

             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)
 

testing/test_python.py

         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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.