当前位置: 首页>>代码示例>>Python>>正文


Python resolver.AsyncResolver类代码示例

本文整理汇总了Python中aiohttp.resolver.AsyncResolver的典型用法代码示例。如果您正苦于以下问题:Python AsyncResolver类的具体用法?Python AsyncResolver怎么用?Python AsyncResolver使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AsyncResolver类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_async_resolver_positive_lookup

def test_async_resolver_positive_lookup(loop):
    with patch('aiodns.DNSResolver.query') as mock_query:
        mock_query.return_value = fake_result(['127.0.0.1'])
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve('www.python.org')
        ipaddress.ip_address(real[0]['host'])
        mock_query.assert_called_with('www.python.org', 'A')
开发者ID:argaen,项目名称:aiohttp,代码行数:7,代码来源:test_resolver.py

示例2: test_async_resolver_query_negative_lookup

def test_async_resolver_query_negative_lookup(loop):
    with patch('aiodns.DNSResolver') as mock:
        del mock().gethostbyname
        mock().query.side_effect = aiodns.error.DNSError()
        resolver = AsyncResolver(loop=loop)
        with pytest.raises(aiodns.error.DNSError):
            yield from resolver.resolve('doesnotexist.bla')
开发者ID:cynecx,项目名称:aiohttp,代码行数:7,代码来源:test_resolver.py

示例3: test_async_resolver_positive_lookup

def test_async_resolver_positive_lookup(loop):
    with patch("aiodns.DNSResolver") as mock:
        mock().gethostbyname.return_value = fake_result(["127.0.0.1"])
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve("www.python.org")
        ipaddress.ip_address(real[0]["host"])
        mock().gethostbyname.assert_called_with("www.python.org", socket.AF_INET)
开发者ID:playpauseandstop,项目名称:aiohttp,代码行数:7,代码来源:test_resolver.py

示例4: test_async_resolver_no_hosts_in_query

def test_async_resolver_no_hosts_in_query(loop):
    with patch('aiodns.DNSResolver') as mock:
        del mock().gethostbyname
        mock().query.return_value = fake_query_result([])
        resolver = AsyncResolver(loop=loop)
        with pytest.raises(OSError):
            yield from resolver.resolve('doesnotexist.bla')
开发者ID:Eyepea,项目名称:aiohttp,代码行数:7,代码来源:test_resolver.py

示例5: test_async_resolver_query_multiple_replies

def test_async_resolver_query_multiple_replies(loop):
    with patch('aiodns.DNSResolver') as mock:
        del mock().gethostbyname
        ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
        mock().query.return_value = fake_query_result(ips)
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve('www.google.com')
        ips = [ipaddress.ip_address(x['host']) for x in real]
开发者ID:cynecx,项目名称:aiohttp,代码行数:8,代码来源:test_resolver.py

示例6: test_async_resolver_multiple_replies

def test_async_resolver_multiple_replies(loop):
    with patch('aiodns.DNSResolver.query') as mock_query:
        ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
        mock_query.return_value = fake_result(ips)
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve('www.google.com')
        ips = [ipaddress.ip_address(x['host']) for x in real]
        assert len(ips) > 3, "Expecting multiple addresses"
开发者ID:argaen,项目名称:aiohttp,代码行数:8,代码来源:test_resolver.py

示例7: test_async_resolver_query_ipv6_positive_lookup

def test_async_resolver_query_ipv6_positive_lookup(loop):
    with patch("aiodns.DNSResolver") as mock:
        del mock().gethostbyname
        mock().query.return_value = fake_query_result(["::1"])
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve("www.python.org", family=socket.AF_INET6)
        ipaddress.ip_address(real[0]["host"])
        mock().query.assert_called_with("www.python.org", "AAAA")
开发者ID:playpauseandstop,项目名称:aiohttp,代码行数:8,代码来源:test_resolver.py

示例8: test_async_resolver_ipv6_positive_lookup

def test_async_resolver_ipv6_positive_lookup(loop):
    with patch('aiodns.DNSResolver') as mock:
        mock().gethostbyname.return_value = fake_result(['::1'])
        resolver = AsyncResolver(loop=loop)
        real = yield from resolver.resolve('www.python.org',
                                           family=socket.AF_INET6)
        ipaddress.ip_address(real[0]['host'])
        mock().gethostbyname.assert_called_with('www.python.org',
                                                socket.AF_INET6)
开发者ID:cynecx,项目名称:aiohttp,代码行数:9,代码来源:test_resolver.py

示例9: go

 def go():
     with patch('aiodns.DNSResolver.query') as mock_query:
         mock_query.side_effect = aiodns.error.DNSError()
         resolver = AsyncResolver(loop=loop)
         try:
             yield from resolver.resolve('doesnotexist.bla')
             assert False, "Expecting aiodns.error.DNSError"
         except aiodns.error.DNSError:
             pass
开发者ID:1st1,项目名称:aiohttp,代码行数:9,代码来源:test_resolver.py

示例10: test_close_for_async_resolver

def test_close_for_async_resolver(loop):
    resolver = AsyncResolver(loop=loop)
    yield from resolver.close()
开发者ID:cynecx,项目名称:aiohttp,代码行数:3,代码来源:test_resolver.py

示例11: test_async_negative_lookup

def test_async_negative_lookup(loop):
    with patch('aiodns.DNSResolver.query') as mock_query:
        mock_query.side_effect = aiodns.error.DNSError()
        resolver = AsyncResolver(loop=loop)
        with pytest.raises(aiodns.error.DNSError):
            yield from resolver.resolve('doesnotexist.bla')
开发者ID:argaen,项目名称:aiohttp,代码行数:6,代码来源:test_resolver.py

示例12: test_async_resolver_negative_lookup

def test_async_resolver_negative_lookup(loop):
    with patch("aiodns.DNSResolver") as mock:
        mock().gethostbyname.side_effect = aiodns.error.DNSError()
        resolver = AsyncResolver(loop=loop)
        with pytest.raises(aiodns.error.DNSError):
            yield from resolver.resolve("doesnotexist.bla")
开发者ID:playpauseandstop,项目名称:aiohttp,代码行数:6,代码来源:test_resolver.py


注:本文中的aiohttp.resolver.AsyncResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。