195 # set explicit test description |
195 # set explicit test description |
196 if rset is not None: |
196 if rset is not None: |
197 self.set_description("testing %s, mod=%s (%s)" % (vid, view.__module__, rset.printable_rql())) |
197 self.set_description("testing %s, mod=%s (%s)" % (vid, view.__module__, rset.printable_rql())) |
198 else: |
198 else: |
199 self.set_description("testing %s, mod=%s (no rset)" % (vid, view.__module__)) |
199 self.set_description("testing %s, mod=%s (no rset)" % (vid, view.__module__)) |
200 viewfunc = lambda **k: self.vreg.main_template(req, template, **kwargs) |
|
201 if template is None: # raw view testing, no template |
200 if template is None: # raw view testing, no template |
202 viewfunc = view.dispatch |
201 viewfunc = view.dispatch |
203 elif template == 'main-template': |
202 else: |
204 _select_view_and_rset = TheMainTemplate._select_view_and_rset |
203 templateview = self.vreg.select_view(template, req, rset, view=view, **kwargs) |
205 # patch TheMainTemplate.process_rql to avoid recomputing resultset |
204 kwargs['view'] = view |
206 def __select_view_and_rset(self, view=view, rset=rset): |
205 viewfunc = lambda **k: self.vreg.main_template(req, template, **kwargs) |
207 self.rset = rset |
206 return self._test_view(viewfunc, view, template, kwargs) |
208 return view, rset |
207 |
209 TheMainTemplate._select_view_and_rset = __select_view_and_rset |
208 |
210 try: |
209 def _test_view(self, viewfunc, view, template='main-template', kwargs={}): |
211 return self._test_view(viewfunc, view, template, **kwargs) |
|
212 finally: |
|
213 if template == 'main-template': |
|
214 TheMainTemplate._select_view_and_rset = _select_view_and_rset |
|
215 |
|
216 |
|
217 def _test_view(self, viewfunc, view, template='main-template', **kwargs): |
|
218 """this method does the actual call to the view |
210 """this method does the actual call to the view |
219 |
211 |
220 If no error occured while rendering the view, the HTML is analyzed |
212 If no error occured while rendering the view, the HTML is analyzed |
221 and parsed. |
213 and parsed. |
222 |
214 |