o
    e9                     @   sp   d Z ddlmZmZmZ dd ZdddZdd	 Zdd
dZdd Z	dd Z
dddZedkr6ee  dS dS )z
Test environment setup.

This establishes the resources that are available for use,
which are tested with `support.is_resource_enabled`.

    )absolute_importdivisionprint_functionc                  C   s6   zddl m}  W n ty   d} Y nw t| dg S )z&Return a fresh list of resource names.r   ALL_RESOURCES)ZaudioZcursesZ	largefilenetworkZbsddbdecimalcpu
subprocessZurlfetchguiZxpickleZgevent_monkey)Ztest.libregrtestr   ImportErrorlistr    r   HD:\Projects\ConvertPro\env\Lib\site-packages\gevent/testing/resources.pyget_ALL_RESOURCES#   s   r   Nc                 C   s   | d u rdd l }|jd} t }| s|S | d}|D ]0}|s!q|dkr)t }q|dkr0g }q|drG|dd  |v rF||dd   q|| q|S )Nr   ZGEVENTTEST_USE_RESOURCES,allnone-   )osenvirongetr   split
startswithremoveappend)Zresource_strr   	resourcesZrequested_resourcesZrequested_resourcer   r   r   parse_resourcesG   s(   

r   c                 C   sR   t t }t | }||krd}|S | r%|| }dtdd |D }|S d}|S )z}
    Given a list of enabled resources, produce the correct environment variable
    setting to enable (only) that list.
    r    c                 s   s    | ]}d | V  qdS )r   Nr   ).0xr   r   r   	<genexpr>   s    z$unparse_resources.<locals>.<genexpr>r   )setr   joinsorted)r   Zall_resourcesenabledresultZexplicitly_disabledr   r   r   unparse_resources   s   
r(   c                 C   s:   t | ts	| du rt| } ddlm} t| |_d|_| S )z
    Call either with a list of resources or a resource string.

    If ``None`` is given, get the resource string from the environment.
    Nr   supportT)
isinstancestrr   r   r*   r   Zuse_resourcesgevent_has_setup_resources)r   r*   r   r   r   setup_resources   s   
r.   c                  C   s   ddl m}  | jst  | S )Nr   r)   )r   r*   r-   r.   r)   r   r   r   ensure_setup_resources   s   r/   c                 C   s4   t  | std| f  ddl}|d dS dS )z
    Call this in standalone test modules that can't use unittest.SkipTest.

    Exits with a status of 0 if the resource isn't enabled.
    zSkipped: %r not enabledr   N)r/   is_resource_enabledprintsysexit)resourcer2   r   r   r   exit_without_resource   s
   r5   r   c                 C   sF   d| f }|s
|}n|d | d }t  | s!dd l}||d S )NzRequires resource %rz ()r   )r/   r0   unittestZSkipTest)r4   reasonrequiresr7   r   r   r   skip_without_resource   s   

r:   __main__)N)r   )__doc__
__future__r   r   r   r   r   r(   r.   r/   r5   r:   __name__r1   r   r   r   r   <module>   s   
$;


