(self)
| 234 | self.assertEqual(response.headers["Location"], "http://0.0.0.0:8080/x/blog/bar") |
| 235 | |
| 236 | def test_processors(self): |
| 237 | urls = ("/(.*)", "blog") |
| 238 | |
| 239 | class blog: |
| 240 | def GET(self, path): |
| 241 | return "blog " + path |
| 242 | |
| 243 | state = web.storage(x=0, y=0) |
| 244 | |
| 245 | def f(): |
| 246 | state.x += 1 |
| 247 | |
| 248 | app_blog = web.application(urls, locals()) |
| 249 | app_blog.add_processor(web.loadhook(f)) |
| 250 | |
| 251 | # fmt: off |
| 252 | urls = ( |
| 253 | "/blog", app_blog, |
| 254 | "/(.*)", "index" |
| 255 | ) |
| 256 | # fmt: on |
| 257 | |
| 258 | class index: |
| 259 | def GET(self, path): |
| 260 | return "hello " + path |
| 261 | |
| 262 | app = web.application(urls, locals()) |
| 263 | |
| 264 | def g(): |
| 265 | state.y += 1 |
| 266 | |
| 267 | app.add_processor(web.loadhook(g)) |
| 268 | |
| 269 | app.request("/blog/foo") |
| 270 | assert state.x == 1 and state.y == 1, repr(state) |
| 271 | app.request("/foo") |
| 272 | assert state.x == 1 and state.y == 2, repr(state) |
| 273 | |
| 274 | def testUnicodeInput(self): |
| 275 | urls = ("(/.*)", "foo") |
nothing calls this directly
no test coverage detected