o
    tPf9                     @   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)audiocurses	largefilenetworkbsddbdecimalcpu
subprocessurlfetchguixpicklegevent_monkey)test.libregrtestr   ImportErrorlistr    r   Y/var/www/html/humari/django-venv/lib/python3.10/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   GEVENTTEST_USE_RESOURCES,allnone-   )osenvirongetr   split
startswithremoveappend)resource_strr   	resourcesrequested_resources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'   all_resourcesenabledresultexplicitly_disabledr   r   r   unparse_resources   s   
r6   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+   r8   r   use_resourcesgevent_has_setup_resources)r'   r8   r   r   r   setup_resources   s   
r=   c                  C   s   ddl m}  | jst  | S )Nr   r7   )r+   r8   r<   r=   r7   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)resourcerA   r   r   r   exit_without_resource   s
   rD   r+   c                 C   sF   d| f }|s
|}n|d | d }t  | s!dd l}||d S )NzRequires resource %rz ()r   )r>   r?   unittestSkipTest)rC   reasonrequiresrF   r   r   r   skip_without_resource   s   

rJ   __main__)N)r+   )__doc__
__future__r   r   r   r   r*   r6   r=   r>   rD   rJ   __name__r@   r   r   r   r   <module>   s   
$;


