# HG changeset patch # User Julien Cristau # Date 1361528222 -3600 # Node ID b399c87df63c1b880a442f23f34e46921204dfcc # Parent d2f01aaae8c0a1425e94cad03559a6cc34e6aed7 [devtools] add http_publish to CubicWebTC (closes #2565882) Fakes a http request, without overriding the normal error handling. Returns the request object so the caller can check for errors. diff -r d2f01aaae8c0 -r b399c87df63c devtools/testlib.py --- a/devtools/testlib.py Fri Jan 18 12:47:40 2013 +0100 +++ b/devtools/testlib.py Fri Feb 22 11:17:02 2013 +0100 @@ -705,6 +705,20 @@ ctrlid, rset = self.app.url_resolver.process(req, req.relative_path(False)) return self.ctrl_publish(req, ctrlid, rset) + def http_publish(self, url, data=None): + """like `url_publish`, except this returns a http response, even in case of errors""" + req = self.req_from_url(url) + if data is not None: + req.form.update(data) + # remove the monkey patched error handler + fake_error_handler = self.app.error_handler + del self.app.error_handler + try: + result = self.app_handle_request(req, req.relative_path(False)) + finally: + self.app.error_handler = fake_error_handler + return result, req + @staticmethod def _parse_location(req, location): try: