Ejemplo n.º 1
0
    def test_get_connection_response(self):
        """Ensure that buffering is in kwargs."""
        class MockConn(object):
            def getresponse(self, *args, **kwargs):
                if PY3:
                    assert "buffering" not in kwargs
                else:
                    assert "buffering" in kwargs

        mock = MockConn()
        get_connection_response(mock)
Ejemplo n.º 2
0
def _make_uds_server(path, request_handler):
    server = UDSHTTPServer(path, request_handler)
    t = threading.Thread(target=server.serve_forever)
    # Set daemon just in case something fails
    t.daemon = True
    t.start()

    # Wait for the server to start
    resp = None
    while resp != 200:
        conn = UDSHTTPConnection(server.server_address, _HOST, 2019)
        try:
            conn.request("PUT", "/")
            resp = get_connection_response(conn).status
        finally:
            conn.close()
        time.sleep(0.01)

    return server, t