當前位置: 首頁>>代碼示例>>Python>>正文


Python AsyncResolver.resolve方法代碼示例

本文整理匯總了Python中aiohttp.resolver.AsyncResolver.resolve方法的典型用法代碼示例。如果您正苦於以下問題:Python AsyncResolver.resolve方法的具體用法?Python AsyncResolver.resolve怎麽用?Python AsyncResolver.resolve使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aiohttp.resolver.AsyncResolver的用法示例。


在下文中一共展示了AsyncResolver.resolve方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_async_resolver_positive_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:9,代碼來源:test_resolver.py

示例2: test_async_resolver_query_negative_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:9,代碼來源:test_resolver.py

示例3: test_async_resolver_positive_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:9,代碼來源:test_resolver.py

示例4: test_async_resolver_no_hosts_in_query

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:9,代碼來源:test_resolver.py

示例5: test_async_resolver_query_multiple_replies

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:10,代碼來源:test_resolver.py

示例6: test_async_resolver_multiple_replies

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:10,代碼來源:test_resolver.py

示例7: test_async_resolver_query_ipv6_positive_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:10,代碼來源:test_resolver.py

示例8: test_async_resolver_ipv6_positive_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:11,代碼來源:test_resolver.py

示例9: go

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
 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,代碼行數:11,代碼來源:test_resolver.py

示例10: test_async_negative_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:8,代碼來源:test_resolver.py

示例11: test_async_resolver_negative_lookup

# 需要導入模塊: from aiohttp.resolver import AsyncResolver [as 別名]
# 或者: from aiohttp.resolver.AsyncResolver import resolve [as 別名]
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,代碼行數:8,代碼來源:test_resolver.py


注:本文中的aiohttp.resolver.AsyncResolver.resolve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。