diff --git a/CHANGELOG b/CHANGELOG index 61a19fd0c..171d2c067 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ Changes between 2.2.1 and 2.2.2.dev - 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 --git a/_pytest/python.py b/_pytest/python.py index 770524984..5289fe6f5 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -629,9 +629,11 @@ class Metafunc: 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 --git a/testing/test_python.py b/testing/test_python.py index ad602d5a9..b39ca6a16 100644 --- a/testing/test_python.py +++ b/testing/test_python.py @@ -983,11 +983,12 @@ class TestMetafunc: 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