@@ -0,0 +1,2350 @@
+%22%22%22Tests for the HTTP server.%22%22%22%0A# -*- coding: utf-8 -*-%0A# vim: set fileencoding=utf-8 :%0A%0Aimport os%0Aimport tempfile%0Aimport threading%0Aimport time%0A%0Aimport pytest%0A%0Aimport cheroot.server%0A%0Afrom cheroot.testing import (%0A    ANY_INTERFACE_IPV4,%0A    ANY_INTERFACE_IPV6,%0A    EPHEMERAL_PORT,%0A)%0A%0A%0Adef make_http_server(bind_addr):%0A    %22%22%22Create and start an HTTP server bound to bind_addr.%22%22%22%0A    httpserver = cheroot.server.HTTPServer(%0A        bind_addr=bind_addr,%0A        gateway=cheroot.server.Gateway,%0A    )%0A%0A    threading.Thread(target=httpserver.safe_start).start()%0A%0A    while not httpserver.ready:%0A        time.sleep(0.1)%0A%0A    return httpserver%0A%0A%0A@pytest.fixture%0Adef http_server():%0A    %22%22%22Provision a server creator as a fixture.%22%22%22%0A    def start_srv():%0A        bind_addr = yield%0A        httpserver = make_http_server(bind_addr)%0A        yield httpserver%0A        yield httpserver%0A%0A    srv_creator = iter(start_srv())%0A    next(srv_creator)%0A    yield srv_creator%0A    try:%0A        while True:%0A            httpserver = next(srv_creator)%0A            if httpserver is not None:%0A                httpserver.stop()%0A    except StopIteration:%0A        pass%0A%0A%0A@pytest.fixture%0Adef unix_sock_file():%0A    %22%22%22Check that bound UNIX socket address is stored in server.%22%22%22%0A    tmp_sock_fh, tmp_sock_fname = tempfile.mkstemp()%0A%0A    yield tmp_sock_fname%0A%0A    os.close(tmp_sock_fh)%0A    os.unlink(tmp_sock_fname)%0A%0A%0A@pytest.mark.parametrize(%0A    'ip_addr',%0A    (%0A        ANY_INTERFACE_IPV4,%0A        ANY_INTERFACE_IPV6,%0A    )%0A)%0Adef test_bind_addr_inet(http_server, ip_addr):%0A    %22%22%22Check that bound IP address is stored in server.%22%22%22%0A    httpserver = http_server.send((ip_addr, EPHEMERAL_PORT))%0A%0A    assert httpserver.bind_addr%5B0%5D == ip_addr%0A    assert httpserver.bind_addr%5B1%5D != EPHEMERAL_PORT%0A%0A%0Adef test_bind_addr_unix(http_server, unix_sock_file):%0A    %22%22%22Check that bound UNIX socket address is stored in server.%22%22%22%0A    httpserver = http_server.send(unix_sock_file)%0A%0A    assert httpserver.bind_addr == unix_sock_file%0A%0A%0A@pytest.mark.skip  # FIXME: investigate binding to abstract sockets issue%0Adef test_bind_addr_unix_abstract(http_server):%0A    %22%22%22Check that bound UNIX socket address is stored in server.%22%22%22%0A    unix_abstract_sock = b'%5Cx00cheroot/test/socket/here.sock'%0A    httpserver = http_server.send(unix_abstract_sock)%0A%0A    assert httpserver.bind_addr == unix_abstract_sock%0A

Add basic tests for server.HTTPServer.bind_addr