application.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:py-script 作者: xiaoxiamin 项目源码 文件源码
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")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号