Generate the environment in ``/tmp`` and run the ZEO server process in
    another thread.

def generate_environment():
    """
    Generate the environment in ``/tmp`` and run the ZEO server process in
    another thread.
    """
    global TMP_PATH
    TMP_PATH = tempfile.mkdtemp()

    # write ZEO server config to  temp directory
    zeo_conf_path = os.path.join(TMP_PATH, "zeo.conf")
    with open(zeo_conf_path, "w") as f:
        f.write(
            Template(data_context("zeo.conf")).substitute(
                path=TMP_PATH,
                server=ZEO_SERVER,
                port=ZEO_PORT,
            )
        )

    # write client config to temp directory
    client_config_path = os.path.join(TMP_PATH, "zeo_client.conf")
    with open(client_config_path, "w") as f:
        f.write(
            Template(data_context("zeo_client.conf")).substitute(
                server=ZEO_SERVER,
                port=ZEO_PORT,
            )
        )

    # run the ZEO server
    def run_zeo():
        global SERV
        SERV = subprocess.Popen(["runzeo", "-C", zeo_conf_path])

    serv = threading.Thread(target=run_zeo)
    serv.setDaemon(True)
    serv.start()