From 50c9e3f654bc845d0c8cd3b4fc29504148a8eec5 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Sat, 19 Nov 2011 23:45:05 +0000 Subject: [PATCH] improve parametrize() docs --- _pytest/python.py | 19 ++++++++++--------- doc/funcargs.txt | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/_pytest/python.py b/_pytest/python.py index 03e68d6d3..f04d5548a 100644 --- a/_pytest/python.py +++ b/_pytest/python.py @@ -588,22 +588,23 @@ class Metafunc: self._ids = py.builtin.set() def parametrize(self, argnames, argvalues, indirect=False, ids=None): - """ parametrize calls to the underlying test function during - the collection phase of a test run. parametrize may be called - multiple times for disjunct argnames sets. + """ 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 + you may pass indirect=True and implement a funcarg factory which can + perform the expensive setup just before a test is actually run. :arg argnames: an argument name or a list of argument names - :arg argvalues: a list of values for a single argument if argnames - specified a single argument only or a list of tuples which specify - values for the multiple argument names. + :arg argvalues: a list of values for the argname or a list of tuples of + values for the list of argument names. :arg indirect: if True each argvalue corresponding to an argument will be - passed as request.param to the respective funcarg factory so that + passed as request.param to its respective funcarg factory so that it can perform more expensive setups during the setup phase of - a test rather than at collection time (which is the default). + a test rather than at collection time. - :arg ids: list of string ids corresponding to the (list of) argvalues + :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. """ diff --git a/doc/funcargs.txt b/doc/funcargs.txt index 56a034dc7..9a89cc137 100644 --- a/doc/funcargs.txt +++ b/doc/funcargs.txt @@ -240,5 +240,5 @@ in the class or module where a test function is defined: ``metafunc.config``: access to command line opts and general config -.. automethod:: Metafunc.parametrize(name, values, idmaker=None) -.. automethod:: Metafunc.addcall(funcargs=None, id=_notexists, param=_notexists) +.. automethod:: Metafunc.parametrize +.. automethod:: Metafunc.addcall(funcargs=None,id=_notexists,param=_notexists)