
    i9                         d Z ddlmZmZmZ d ZddZd ZddZd Z	d	 Z
ddZedk    r e 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                  \    	 ddl m}  n# t          $ r d} Y nw xY wt          |           dgz   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   s    C/usr/local/lib/python3.11/dist-packages/gevent/testing/resources.pyget_ALL_RESOURCESr   #   sa    
2222222 
 
 


* "  s   	 Nc                    | dd l }|j                            d          } t                      }| s|S |                     d          }|D ]w}|s|dk    rt                      }|dk    rg }#|                    d          r*|dd          |v r|                    |dd                     b|                    |           x|S )Nr   GEVENTTEST_USE_RESOURCES,allnone-   )osenvirongetr   split
startswithremoveappend)resource_strr!   	resourcesrequested_resourcesrequested_resources        r   parse_resourcesr,   G   s   : 			z~~&@AA!##I &,,S111 1 1 " 	&&)++II6))II**3// 	1!!""%22  !3ABB!7888 /0000    c                     t          t                                }t          |           }||k    rd}n6| r2||z
  }d                    t          d |D                                 }nd}|S )z}
    Given a list of enabled resources, produce the correct environment variable
    setting to enable (only) that list.
    r    c              3       K   | ]	}d |z   V  
dS )r   N ).0xs     r   	<genexpr>z$unparse_resources.<locals>.<genexpr>   s&      EEAaEEEEEEr-   r   )setr   joinsorted)r)   all_resourcesenabledresultexplicitly_disableds        r   unparse_resourcesr<      s}      )++,,M)nnG-	 +g5EE1DEEEEEFFMr-   c                     t          | t                    s| 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   use_resourcesgevent_has_setup_resources)r)   r?   s     r   setup_resourcesrD      sV     )S!! /Y%6#I..	 OOG)-G&r-   c                  <    ddl m}  | j        st                       | S )Nr    r>   )r/   r?   rC   rD   r>   s    r   ensure_setup_resourcesrF      s2     - Nr-   c                     t                                          |           s.t          d| d           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: z not enabledr   N)rF   is_resource_enabledprintsysexit)resourcerJ   s     r   exit_without_resourcerM      s]     "##77AA 8885666


 r-   r/   c                     d| }|s|}n|dz   |z   dz   }t                                          |           sdd l}|                    |          d S )NzRequires resource z ()r   )rF   rH   unittestSkipTest)rL   reasonrequiresrP   s       r   skip_without_resourcerT      ss     )13H 0$)C/!##77AA ('''( (r-   __main__)N)r/   )__doc__
__future__r   r   r   r   r,   r<   rD   rF   rM   rT   __name__rI   r1   r-   r   <module>rY      s   ,  A @ @ @ @ @ @ @ @ @! ! !H9 9 9 9v  :      
 
 
	( 	( 	( 	( z	E//

 r-   