[py-svn] commit/pytest: RonnyPfannschmidt: no longer check if indirect metafunc.parametrize params are funcarg names

Bitbucket commits-noreply at bitbucket.org
Fri Feb 3 17:15:52 CET 2012


1 new commit in pytest:


https://bitbucket.org/hpk42/pytest/changeset/c60327d4ed28/
changeset:   c60327d4ed28
user:        RonnyPfannschmidt
date:        2012-02-03 16:54:00
summary:     no longer check if indirect metafunc.parametrize params are funcarg names
affected #:  3 files

diff -r 0abb489082fd4b6da3554c41c497d5bdbf9a80aa -r c60327d4ed285d589d8c0b7dfcf7b1f19b40aa63 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,6 +10,7 @@
 - fix issue106: allow parametrize to be applied multiple times
   e.g. from module, class and at function level.
 - fix issue107: actually perform session scope finalization
+- don't check in parametrize if indirect parameters are funcarg names
 - add chdir method to monkeypatch funcarg
 - fix crash resulting from calling monkeypatch undo a second time
 - extend reports accepting kwargs to set arbitrary additional attributes


diff -r 0abb489082fd4b6da3554c41c497d5bdbf9a80aa -r c60327d4ed285d589d8c0b7dfcf7b1f19b40aa63 _pytest/python.py
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -629,9 +629,11 @@
         if not isinstance(argnames, (tuple, list)):
             argnames = (argnames,)
             argvalues = [(val,) for val in argvalues]
-        for arg in argnames:
-            if arg not in self.funcargnames:
-                raise ValueError("%r has no argument %r" %(self.function, arg))
+        if not indirect:
+            #XXX should we also check for the opposite case?
+            for arg in argnames:
+                if arg not in self.funcargnames:
+                    raise ValueError("%r has no argument %r" %(self.function, arg))
         valtype = indirect and "params" or "funcargs"
         if not ids:
             idmaker = IDMaker()


diff -r 0abb489082fd4b6da3554c41c497d5bdbf9a80aa -r c60327d4ed285d589d8c0b7dfcf7b1f19b40aa63 testing/test_python.py
--- a/testing/test_python.py
+++ b/testing/test_python.py
@@ -983,11 +983,12 @@
         metafunc = funcargs.Metafunc(func)
         metafunc.parametrize('x', [1], indirect=True)
         metafunc.parametrize('y', [2,3], indirect=True)
+        metafunc.parametrize('unnamed', [1], indirect=True)
         assert len(metafunc._calls) == 2
         assert metafunc._calls[0].funcargs == {}
         assert metafunc._calls[1].funcargs == {}
-        assert metafunc._calls[0].params == dict(x=1,y=2)
-        assert metafunc._calls[1].params == dict(x=1,y=3)
+        assert metafunc._calls[0].params == dict(x=1,y=2, unnamed=1)
+        assert metafunc._calls[1].params == dict(x=1,y=3, unnamed=1)
 
     def test_addcalls_and_parametrize_indirect(self):
         def func(x, y): pass

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the pytest-commit mailing list