a
    mzf
                     @   s   d Z ddlZddlZddlZddlmZmZ ddlmZm	Z	 ddl
mZmZmZmZ ddl
mZ ejdd	 Zejd
d Zejdd Zejdd Zejdd Zejdd Zdd ZdS )zPytest configuration module.

Contains fixtures, which are tightly bound to the Cheroot framework
itself, useless for end-users' app testing.
    N   IS_MACOS
IS_WINDOWS)Gateway
HTTPServer)native_serverthread_and_wsgi_serverthread_and_native_serverwsgi_serverget_server_clientc                  C   s    d} t r| d9 } tr| d9 } | S )z<Return a common HTTP request timeout for tests with queries.皙?r   
   r   )Zcomputed_timeout r   C/var/www/media/lib/python3.9/site-packages/cheroot/test/conftest.pyhttp_request_timeout   s    r   c                 C   s   | \}}|S )z^Set up and tear down a Cheroot WSGI server instance.

    This exposes the server thread.
    r   )r	   server_thread_srvr   r   r   wsgi_server_thread%   s    r   c                 C   s   | \}}|S )z^Set up and tear down a Cheroot HTTP server instance.

    This exposes the server thread.
    r   )r
   r   r   r   r   r   native_server_thread0   s    r   c                 C   s   t | S )z.Create a test client out of given WSGI server.r   )r   r   r   r   wsgi_server_client;   s    r   c                 C   s   t | S )z.Create a test client out of given HTTP server.r   )r   r   r   r   native_server_clientB   s    r   c                  c   sV   dd } t |  }t| |V  zt|}|dur"|  q"W n tyP   Y n0 dS )z(Provision a server creator as a fixture.c                  s   s*   d V } | d u rd S t | }|V  |V  d S )N)make_http_server	bind_addr
httpserverr   r   r   	start_srvL   s    zhttp_server.<locals>.start_srvN)iternextstopStopIteration)r   Zsrv_creatorr   r   r   r   http_serverI   s    
r"   c                 C   s4   t | td}tj|jd  |js0td q|S )z7Create and start an HTTP server bound to ``bind_addr``.)r   Zgateway)targetr   )	r   r   	threadingThreadZ
safe_startstartreadytimesleepr   r   r   r   r   `   s    r   )__doc__r$   r(   Zpytest_compatr   r   serverr   r   Ztestingr   r	   r
   r   r   Zfixturer   r   r   r   r   r"   r   r   r   r   r   <module>   s(   

	
	


