Пример #1
0
def test_threaded_resolver_multiple_replies(loop):
    ips = ["127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4"]
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver(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"
Пример #2
0
def test_threaded_negative_lookup():
    loop = Mock()
    ips = []
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver(loop=loop)
    with pytest.raises(socket.gaierror):
        yield from resolver.resolve('doesnotexist.bla')
Пример #3
0
def test_threaded_resolver_multiple_replies(loop):
    ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver(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"
Пример #4
0
def test_threaded_resolver_multiple_replies(loop):
    ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver(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"
Пример #5
0
async def test_threaded_resolver_positive_lookup() -> None:
    loop = Mock()
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = ThreadedResolver()
    resolver._loop = loop
    real = await resolver.resolve('www.python.org')
    ipaddress.ip_address(real[0]['host'])
def function1287():
    var1031 = Mock()
    var2205 = []
    var1031.getaddrinfo = function1518(var2205)
    var2284 = ThreadedResolver(loop=var1031)
    with pytest.raises(socket.gaierror):
        yield from var2284.resolve('doesnotexist.bla')
Пример #7
0
def test_threaded_negative_lookup():
    loop = Mock()
    ips = []
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver(loop=loop)
    with pytest.raises(socket.gaierror):
        yield from resolver.resolve('doesnotexist.bla')
def function2200():
    var4211 = Mock()
    var1632 = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
    var4211.getaddrinfo = function1518(var1632)
    var4037 = ThreadedResolver(loop=var4211)
    var911 = yield from var4037.resolve('www.google.com')
    var1632 = [ipaddress.ip_address(var1531['host']) for var1531 in var911]
    assert (len(var1632) > 3), 'Expecting multiple addresses'
Пример #9
0
async def test_threaded_resolver_positive_lookup() -> None:
    loop = Mock()
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = ThreadedResolver()
    resolver._loop = loop
    real = await resolver.resolve("www.python.org")
    assert real[0]["hostname"] == "www.python.org"
    ipaddress.ip_address(real[0]["host"])
Пример #10
0
async def test_threaded_negative_lookup() -> None:
    loop = Mock()
    ips = []
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver()
    resolver._loop = loop
    with pytest.raises(socket.gaierror):
        await resolver.resolve('doesnotexist.bla')
Пример #11
0
async def test_threaded_resolver_multiple_replies() -> None:
    loop = Mock()
    ips = ["127.0.0.1", "127.0.0.2", "127.0.0.3", "127.0.0.4"]
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver()
    resolver._loop = loop
    real = await resolver.resolve("www.google.com")
    ips = [ipaddress.ip_address(x["host"]) for x in real]
    assert len(ips) > 3, "Expecting multiple addresses"
Пример #12
0
async def test_threaded_resolver_multiple_replies() -> None:
    loop = Mock()
    ips = ['127.0.0.1', '127.0.0.2', '127.0.0.3', '127.0.0.4']
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = ThreadedResolver()
    resolver._loop = loop
    real = await resolver.resolve('www.google.com')
    ips = [ipaddress.ip_address(x['host']) for x in real]
    assert len(ips) > 3, "Expecting multiple addresses"
Пример #13
0
async def test_threaded_negative_lookup_with_unknown_result() -> None:
    loop = Mock()

    # If compile CPython with `--disable-ipv6` option,
    # we will get an (int, bytes) tuple, instead of a Exception.
    async def unknown_addrinfo(*args: Any, **kwargs: Any) -> List[Any]:
        return [(
            socket.AF_INET6,
            socket.SOCK_STREAM,
            6,
            "",
            (10, b"\x01\xbb\x00\x00\x00\x00*\x04NB\x00\x1a\x00\x00"),
        )]

    loop.getaddrinfo = unknown_addrinfo
    resolver = ThreadedResolver()
    resolver._loop = loop
    with patch("socket.has_ipv6", False):
        res = await resolver.resolve("www.python.org")
    assert len(res) == 0
def function1893():
    var3559 = Mock()
    var3559.getaddrinfo = function1518(['127.0.0.1'])
    var3401 = ThreadedResolver(loop=var3559)
    var3891 = yield from var3401.resolve('www.python.org')
    ipaddress.ip_address(var3891[0]['host'])
def function1250(arg1517):
    asyncio.set_event_loop(arg1517)
    var3254 = ThreadedResolver()
    assert (var3254._loop is arg1517)
def function2896(arg1805):
    var4423 = ThreadedResolver(loop=arg1805)
    yield from var4423.close()
Пример #17
0
def test_close_for_threaded_resolver(loop):
    resolver = ThreadedResolver(loop=loop)
    yield from resolver.close()
Пример #18
0
async def test_close_for_threaded_resolver(loop) -> None:
    resolver = ThreadedResolver()
    await resolver.close()
Пример #19
0
def test_threaded_resolver_positive_lookup(loop):
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = ThreadedResolver(loop=loop)
    real = yield from resolver.resolve('www.python.org')
    ipaddress.ip_address(real[0]['host'])
Пример #20
0
async def test_close_for_threaded_resolver(loop):
    resolver = ThreadedResolver(loop=loop)
    await resolver.close()
Пример #21
0
def test_close_for_threaded_resolver(loop):
    resolver = ThreadedResolver(loop=loop)
    yield from resolver.close()
Пример #22
0
async def test_default_loop_for_threaded_resolver(loop) -> None:
    asyncio.set_event_loop(loop)
    resolver = ThreadedResolver()
    assert resolver._loop is loop
Пример #23
0
def test_threaded_resolver_positive_lookup():
    loop = Mock()
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = ThreadedResolver(loop=loop)
    real = yield from resolver.resolve('www.python.org')
    ipaddress.ip_address(real[0]['host'])