[testlib] consider rset for template / view selection (closes #2447183)
The original code did something like:
kwargs['rset'] = rset
viewfunc = lambda **k: viewsreg.main_template(req, template, **kwargs)
kwargs.pop('rset')
return self._test_view(viewfunc, view, template, kwargs)
meaning that by the time ``viewfunc`` (i.e. the lambda function) is called,
``rset`` was popped from ``kwargs`` and had no chance to be passed to ``main_template``.
--- a/devtools/testlib.py Mon Jul 23 22:45:32 2012 +0200
+++ b/devtools/testlib.py Tue Jul 31 10:12:06 2012 +0200
@@ -817,9 +817,8 @@
"""
req = req or rset and rset.req or self.request()
req.form['vid'] = vid
- kwargs['rset'] = rset
viewsreg = self.vreg['views']
- view = viewsreg.select(vid, req, **kwargs)
+ view = viewsreg.select(vid, req, rset=rset, **kwargs)
# set explicit test description
if rset is not None:
self.set_description("testing vid=%s defined in %s with (%s)" % (
@@ -831,10 +830,8 @@
viewfunc = view.render
else:
kwargs['view'] = view
- templateview = viewsreg.select(template, req, **kwargs)
viewfunc = lambda **k: viewsreg.main_template(req, template,
- **kwargs)
- kwargs.pop('rset')
+ rset=rset, **kwargs)
return self._test_view(viewfunc, view, template, kwargs)