Beispiel #1
0
def test_default_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 = DefaultResolver(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"
Beispiel #2
0
def test_default_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 = DefaultResolver(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"
Beispiel #3
0
 def go():
     ips = []
     loop.getaddrinfo = fake_addrinfo(ips)
     resolver = DefaultResolver(loop=loop)
     try:
         yield from resolver.resolve('doesnotexist.bla')
         assert False, "Expecting socket.gaierror"
     except socket.gaierror:
         pass
Beispiel #4
0
 def go():
     ips = []
     loop.getaddrinfo = fake_addrinfo(ips)
     resolver = DefaultResolver(loop=loop)
     try:
         yield from resolver.resolve('doesnotexist.bla')
         assert False, "Expecting socket.gaierror"
     except socket.gaierror:
         pass
Beispiel #5
0
 def __init__(self,
              fakes: Dict[str, int],
              *,
              loop: Optional[AbstractEventLoop] = None) -> None:
     """fakes -- dns -> port dict"""
     loop = loop or get_event_loop()
     self._fakes = fakes
     self._resolver = DefaultResolver(loop=loop)
 def __init__(self, fakes, *, loop):
     """fakes -- dns -> port dict"""
     self._fakes = fakes
     self._resolver = DefaultResolver(loop=loop)
Beispiel #7
0
def test_default_loop_for_default_resolver(loop):
    asyncio.set_event_loop(loop)
    resolver = DefaultResolver()
    assert resolver._loop is loop
Beispiel #8
0
def test_close_for_default_resolver(loop):
    resolver = DefaultResolver(loop=loop)
    yield from resolver.close()
Beispiel #9
0
def test_default_negative_lookup(loop):
    ips = []
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = DefaultResolver(loop=loop)
    with pytest.raises(socket.gaierror):
        yield from resolver.resolve('doesnotexist.bla')
Beispiel #10
0
def test_default_resolver_positive_lookup(loop):
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = DefaultResolver(loop=loop)
    real = yield from resolver.resolve('www.python.org')
    ipaddress.ip_address(real[0]['host'])
Beispiel #11
0
 def go():
     loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
     resolver = DefaultResolver(loop=loop)
     real = yield from resolver.resolve('www.python.org')
     ipaddress.ip_address(real[0]['host'])
Beispiel #12
0
def test_close_for_default_resolver(loop):
    resolver = DefaultResolver(loop=loop)
    yield from resolver.close()
Beispiel #13
0
def test_default_negative_lookup(loop):
    ips = []
    loop.getaddrinfo = fake_addrinfo(ips)
    resolver = DefaultResolver(loop=loop)
    with pytest.raises(socket.gaierror):
        yield from resolver.resolve('doesnotexist.bla')
Beispiel #14
0
def test_default_resolver_positive_lookup(loop):
    loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
    resolver = DefaultResolver(loop=loop)
    real = yield from resolver.resolve('www.python.org')
    ipaddress.ip_address(real[0]['host'])
Beispiel #15
0
 def __init__(self, fakes, loop: asyncio.AbstractEventLoop):
     """fakes -- dns -> port dict"""
     self._fakes = fakes
     self._resolver = DefaultResolver(loop=loop)
Beispiel #16
0
 def go():
     loop.getaddrinfo = fake_addrinfo(["127.0.0.1"])
     resolver = DefaultResolver(loop=loop)
     real = yield from resolver.resolve('www.python.org')
     ipaddress.ip_address(real[0]['host'])