def testCustomNotFound(self):
urls_a = ("/", "a")
urls_b = ("/", "b")
app_a = web.application(urls_a, locals())
app_b = web.application(urls_b, locals())
app_a.notfound = lambda: web.HTTPError("404 Not Found", {}, "not found 1")
urls = (
"/a", app_a,
"/b", app_b
)
app = web.application(urls, locals())
def assert_notfound(path, message):
response = app.request(path)
self.assertEquals(response.status.split()[0], "404")
self.assertEquals(response.data, message)
assert_notfound("/a/foo", "not found 1")
assert_notfound("/b/foo", "not found")
app.notfound = lambda: web.HTTPError("404 Not Found", {}, "not found 2")
assert_notfound("/a/foo", "not found 1")
assert_notfound("/b/foo", "not found 2")
评论列表
文章目录