test_dns.py 文件源码

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

项目:sample-klein-app 作者: wsanchez 项目源码 文件源码
def test_hostname_lookup_error(self) -> None:
        """
        :meth:`.dns.Application.hostname` responds with a
        :const:`twisted.web.http.NOT_FOUND` error if there is a DNS lookup
        error.
        """
        def getHostByName(*args, **kwargs) -> Deferred:
            return fail(DNSLookupError())

        self.patch(dns, "getHostByName", getHostByName)

        self.assertResponse(
            b"/gethostbyname/foo.example.com",
            response_data=b"lookup error",
            response_code=http.NOT_FOUND,
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号