o
    tPf                     @   s   d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ej
eZdd ZdZdded fd	ZG d
d de	jZdd Ze  D ]	\ZZee e< qIedkr]e  dS dS )a  
Test the contents of the ``examples/`` directory.

If an existing test in *this* directory named ``test__example_<fn>.py`` exists,
where ``<fn>`` is the base filename of an example file, it will not be tested
here.

Examples can specify that they need particular test resources to be enabled
by commenting (one per line) ``# gevent-test-requires-resource: <resource>``;
most commonly the resource will be ``network``. You can use this technique to specify
non-existant resources for things that should never be tested.
    N)utilc               	   C   sz   t  } z2t t dd tdD }tjr'tjr/|d W t |  |S W t |  |S W t |  |S t |  w )Nc                 S   s   g | ]}|d d qS )   N ).0xr   r   \/var/www/html/humari/django-venv/lib/python3.10/site-packages/gevent/tests/test__examples.py
<listcomp>   s    z)_find_files_to_ignore.<locals>.<listcomp>ztest__example_*.pyprocesses.py)	osgetcwdchdirthis_dirglob	greentestPYPYRUNNING_ON_APPVEYORappend)old_dirresultr   r   r   _find_files_to_ignore   s   



r   )   
   )r      )zconcurrent_download.pyr	   c                   @   s$   e Zd ZeZdZdd Zdd ZdS )_AbstractTestMixinNc                 C   s   ddl m} ttj| j| jd}| }W d    n1 s!w   Y  t	
dt	j}t	||}|D ]}||d|d }|| q5d S )Nr   )	resourcesrz'^# gevent-test-requires-resource: (.*)$   )gevent.testingr   openr
   pathjoincwdexamplereadrecompile	MULTILINEfinditerstartendskip_without_resource)selfr   fcontentspatternresources_neededmatchneededr   r   r   _check_resources1   s   
z#_AbstractTestMixin._check_resourcesc                 C   sh   |    t }| j\}}|dddddid| _|  s&| d| j  d S t | }| || d S )NTGEVENT_DEBUGerror)timeoutquietbuffer_outputnestedsetenvzFailed example: )r3   time
time_rangestart_kwargsrun_examplefailr#   assertGreaterEqual)r,   r)   min_timemax_timetookr   r   r   	test_runs>   s   
z_AbstractTestMixin.test_runs)__name__
__module____qualname__default_time_ranger<   r#   r3   rD   r   r   r   r   r   -   s
    r   c               	   C   s   i } zt  j}W n tjy   t jddd |  Y S w t }t|d D ]%}tj	
|}||v r4q'td| ttjf|t|tjd}|| |j< q'| S )NzWARNING: No examples dir foundzsuboptimal-behaviour)colorz/*.pyTest_)r#   r<   )r   ExampleMixinr"   unittestSkipTestlogr   r   r
   r    basenametyper   r   TestCasetime_rangesgetr<   rE   )r   example_dirignorefilenamebntcr   r   r   _build_test_classesP   s*   rY   __main__)__doc__r%   r
   r   r;   rL   r   testingr   r   r    dirname__file__r   r   rH   rR   rK   r   rY   itemskvlocalsrE   mainr   r   r   r   <module>   s*    
#