本文整理汇总了Python中tornado.netutil.OverrideResolver.resolve方法的典型用法代码示例。如果您正苦于以下问题:Python OverrideResolver.resolve方法的具体用法?Python OverrideResolver.resolve怎么用?Python OverrideResolver.resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tornado.netutil.OverrideResolver
的用法示例。
在下文中一共展示了OverrideResolver.resolve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OverrideResolverTest
# 需要导入模块: from tornado.netutil import OverrideResolver [as 别名]
# 或者: from tornado.netutil.OverrideResolver import resolve [as 别名]
class OverrideResolverTest(AsyncTestCase, _ResolverTestMixin):
def setUp(self):
super(OverrideResolverTest, self).setUp()
mapping = {
('google.com', 80): ('1.2.3.4', 80),
('google.com', 80, socket.AF_INET): ('1.2.3.4', 80),
('google.com', 80, socket.AF_INET6): ('2a02:6b8:7c:40c:c51e:495f:e23a:3', 80)
}
self.resolver = OverrideResolver(BlockingResolver(), mapping)
@gen_test
def test_resolve_multiaddr(self):
result = yield self.resolver.resolve('google.com', 80, socket.AF_INET)
self.assertIn((socket.AF_INET, ('1.2.3.4', 80)), result)
result = yield self.resolver.resolve('google.com', 80, socket.AF_INET6)
self.assertIn((socket.AF_INET6, ('2a02:6b8:7c:40c:c51e:495f:e23a:3', 80, 0, 0)), result)