Ronny Pfannschmidt avatar Ronny Pfannschmidt committed 2f80818

kill parametrize-items

Comments (0)

Files changed (2)

parametrize-items

-# HG changeset patch
-# Parent 3da8cec6c5326ed27c144c9b6d7a64a648370005
-introduce items kwarg for parametrize  which provides (ids, argvalues) = zip(items)
-
-diff --git a/_pytest/python.py b/_pytest/python.py
---- a/_pytest/python.py
-+++ b/_pytest/python.py
-@@ -589,7 +589,7 @@ class Metafunc:
-         self._calls = []
-         self._ids = py.builtin.set()
- 
--    def parametrize(self, argnames, argvalues, indirect=False, ids=None):
-+    def parametrize(self, argnames, argvalues=None, indirect=False, ids=None, items=None):
-         """ Add new invocations to the underlying test function using the list
-         of argvalues for the given argnames.  Parametrization is performed
-         during the collection phase.  If you need to setup expensive resources
-@@ -609,7 +609,15 @@ class Metafunc:
-         :arg ids: list of string ids each corresponding to the argvalues so
-             that they are part of the test id. If no ids are provided they will
-             be generated automatically from the argvalues.
-+        :arg items: ids, argvalues = zip(items)
-         """
-+        if items is None:
-+            assert argvalues is not None
-+        else:
-+            assert argvalues is None and ids is None
-+
-+            ids, argvalues = zip(*items)
-+
-         if not isinstance(argnames, (tuple, list)):
-             argnames = (argnames,)
-             argvalues = [(val,) for val in argvalues]
-diff --git a/testing/test_python.py b/testing/test_python.py
---- a/testing/test_python.py
-+++ b/testing/test_python.py
-@@ -1048,6 +1048,15 @@ class TestMetafunc:
-         assert metafunc._calls[1].funcargs == dict(x=3, y=4)
-         assert metafunc._calls[1].id == "3-4"
- 
-+    def test_parametrize_items(self):
-+        metafunc = funcargs.Metafunc(lambda x,y: None)
-+        metafunc.parametrize(('x', 'y'), items=[('small', (1,2)), ('big', (3,4))])
-+        assert metafunc._calls[0].id == 'small'
-+        assert metafunc._calls[0].funcargs == dict(x=1, y=2)
-+        assert metafunc._calls[1].id == 'big'
-+        assert metafunc._calls[1].funcargs == dict(x=3, y=4)
-+
-+
- class TestMetafuncFunctional:
-     def test_attributes(self, testdir):
-         p = testdir.makepyfile("""
 handle-usageerror
 asser-reloader-package
 junitxml-partial-writing
-parametrize-items
 regendoc-pytesthighlight #+doc
 fnmatch-python-test-names
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.