(self)
| 264 | root.tooldecs = _test_decorators.ToolExamples() |
| 265 | |
| 266 | def testHookErrors(self): |
| 267 | self.getPage('/demo/?id=1') |
| 268 | # If body is "razdrez", then on_end_request is being called too early. |
| 269 | self.assertBody('A horrorshow lomtick of cherry 3.14159') |
| 270 | # If this fails, then on_end_request isn't being called at all. |
| 271 | time.sleep(0.1) |
| 272 | self.getPage('/demo/ended/1') |
| 273 | self.assertBody('True') |
| 274 | |
| 275 | valerr = '\n raise ValueError()\nValueError' |
| 276 | self.getPage('/demo/err?id=3') |
| 277 | # If body is "razdrez", then on_end_request is being called too early. |
| 278 | self.assertErrorPage(502, pattern=valerr) |
| 279 | # If this fails, then on_end_request isn't being called at all. |
| 280 | time.sleep(0.1) |
| 281 | self.getPage('/demo/ended/3') |
| 282 | self.assertBody('True') |
| 283 | |
| 284 | # If body is "razdrez", then on_end_request is being called too early. |
| 285 | if (cherrypy.server.protocol_version == 'HTTP/1.0' or |
| 286 | getattr(cherrypy.server, 'using_apache', False)): |
| 287 | self.getPage('/demo/errinstream?id=5') |
| 288 | # Because this error is raised after the response body has |
| 289 | # started, the status should not change to an error status. |
| 290 | self.assertStatus('200 OK') |
| 291 | self.assertBody('nonconfidential') |
| 292 | else: |
| 293 | # Because this error is raised after the response body has |
| 294 | # started, and because it's chunked output, an error is raised by |
| 295 | # the HTTP client when it encounters incomplete output. |
| 296 | self.assertRaises((ValueError, IncompleteRead), self.getPage, |
| 297 | '/demo/errinstream?id=5') |
| 298 | # If this fails, then on_end_request isn't being called at all. |
| 299 | time.sleep(0.1) |
| 300 | self.getPage('/demo/ended/5') |
| 301 | self.assertBody('True') |
| 302 | |
| 303 | # Test the "__call__" technique (compile-time decorator). |
| 304 | self.getPage('/demo/restricted') |
| 305 | self.assertErrorPage(401) |
| 306 | |
| 307 | # Test compile-time decorator with kwargs from config. |
| 308 | self.getPage('/demo/userid') |
| 309 | self.assertBody('Welcome!') |
| 310 | |
| 311 | def testEndRequestOnDrop(self): |
| 312 | old_timeout = None |
nothing calls this directly
no test coverage detected