예제 #1
0
def test_nameserver_process_default_host():
    """
    A name server process should default to localhost (127.0.0.1).
    """
    ns = NameServerProcess(1234)
    assert ns.port == 1234
    assert ns.host == '127.0.0.1'
예제 #2
0
def test_nameserver_proxy_timeout():
    """
    When creating a proxy to the name server, there should be a timeout
    before raising an error if the name server cannot be located.
    """
    while True:
        try:
            # Bind to random port
            host = '127.0.0.1'
            port = random.randrange(10000, 20000)
            addr = SocketAddress(host, port)
            nameserver = NameServerProcess(addr)
            # Start name server later
            Timer(1, nameserver.start).start()
            # Locate name server now
            pyro_address = NSProxy(addr, timeout=3.0).addr()
        except PermissionError:
            continue
        break
    assert pyro_address.host == host
    assert pyro_address.port == port
    nameserver.shutdown()
예제 #3
0
def test_nameserver_proxy_timeout():
    """
    When creating a proxy to the name server, there should be a timeout
    before raising an error if the name server cannot be located.
    """
    while True:
        try:
            # Bind to random port
            host = '127.0.0.1'
            port = random.randrange(10000, 20000)
            addr = SocketAddress(host, port)
            nameserver = NameServerProcess(addr)
            # Start name server later
            Timer(1, nameserver.start).start()
            # Locate name server now
            pyro_address = NSProxy(addr, timeout=3.).addr()
        except PermissionError:
            continue
        break
    assert pyro_address.host == host
    assert pyro_address.port == port
    nameserver.shutdown()