From 60a7556ca3b00527bc2a7666df334146d64b612f Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 17 Jul 2009 14:52:11 +0200 Subject: [PATCH] resolves issue 25 fix documentation for cached_setup, thanks to anonymous for reporting. --HG-- branch : 1.0.x --- doc/test/funcargs.txt | 8 ++++---- py/test/funcargs.py | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/doc/test/funcargs.txt b/doc/test/funcargs.txt index 70d5eef4a..96e805a88 100644 --- a/doc/test/funcargs.txt +++ b/doc/test/funcargs.txt @@ -136,12 +136,12 @@ managing fixtures across test modules and test runs .. sourcecode:: python - def cached_setup(setup, teardown=None, scope="module", keyextra=None): + def cached_setup(setup, teardown=None, scope="module", extrakey=None): """ cache and return result of calling setup(). - The scope determines the cache key and ``keyextra`` adds to the cachekey. - The scope also determines when teardown(result) will be called. - valid scopes: + The scope and the ``extrakey`` determine the cache key. + The scope also determines when teardown(result) + will be called. valid scopes are: scope == 'function': when the single test function run finishes. scope == 'module': when tests in a different module are run scope == 'session': when tests of the session have run. diff --git a/py/test/funcargs.py b/py/test/funcargs.py index 251317b29..56b8f1865 100644 --- a/py/test/funcargs.py +++ b/py/test/funcargs.py @@ -103,6 +103,15 @@ class FuncargRequest: self._pyfuncitem.funcargs[argname] = self.getfuncargvalue(argname) def cached_setup(self, setup, teardown=None, scope="module", extrakey=None): + """ cache and return result of calling setup(). + + The scope and the ``extrakey`` determine the cache key. + The scope also determines when teardown(result) + will be called. valid scopes are: + scope == 'function': when the single test function run finishes. + scope == 'module': when tests in a different module are run + scope == 'session': when tests of the session have run. + """ if not hasattr(self.config, '_setupcache'): self.config._setupcache = {} # XXX weakref? cachekey = (self._getscopeitem(scope), extrakey)