resolves issue 25

fix documentation for cached_setup, thanks to anonymous for reporting.

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel 2009-07-17 14:52:11 +02:00
parent 64a5075545
commit 60a7556ca3
2 changed files with 13 additions and 4 deletions

View File

@ -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.

View File

@ -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)