
    i                     Z   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 ZdZdded         fdZ G d	 d
e	j                  Zd Z e                                            D ]\  ZZe e            e<   edk    r ej                     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                  R   t          j                    } 	 t          j        t                     d t	          j        d          D             }t
          j        r!t
          j        r|                    d           t          j        |            n# t          j        |            w xY w|S )Nc                 "    g | ]}|d d         S )   N ).0xs     F/usr/local/lib/python3.11/dist-packages/gevent/tests/test__examples.py
<listcomp>z)_find_files_to_ignore.<locals>.<listcomp>   s     BBBQ!BCC&BBB    ztest__example_*.pyprocesses.py)	osgetcwdchdirthis_dirglob	greentestPYPYRUNNING_ON_APPVEYORappend)old_dirresults     r
   _find_files_to_ignorer      s    ikkG	
BB$),@"A"ABBB> 	*i; 	* MM.)))
Ms   A$B B$)   
   )r      )zconcurrent_download.pyr   c                   "    e Zd ZeZdZd Zd ZdS )_AbstractTestMixinNc                    ddl m} t          t          j                            | j        | j                  d          5 }|                                }d d d            n# 1 swxY w Y   t          j
        dt          j                  }t          j        ||          }|D ]G}||                    d          |                    d                   }|                    |           Hd 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neededs           r
   _check_resourcesz#_AbstractTestMixin._check_resources1   s   ,,,,,, "',,tx66<< 	 vvxxH	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  *FUU;w99% 	4 	4Eekk!nnUYYq\\9:F++F3333	4 	4s   A  A$'A$c                 D   |                                   t          j                    }| j        \  }}|dddddid| _        |                                 s|                     d| j        z              d S t          j                    |z
  }|                     ||           d S )NTGEVENT_DEBUGerror)timeoutquietbuffer_outputnestedsetenvzFailed example: )r9   time
time_rangestart_kwargsrun_examplefailr)   assertGreaterEqual)r2   r/   min_timemax_timetooks        r
   	test_runsz_AbstractTestMixin.test_runs>   s    	!_(!%w/
 
 !! 	4II(4<7888889;;&D##D(33333r   )__name__
__module____qualname__default_time_rangerC   r)   r9   rK   r   r   r
   r   r   -   s<        #JG4 4 44 4 4 4 4r   r   c            
         i } 	 t          j                    j        }n-# t          j        $ r t          j        dd           | cY S w xY wt                      }t          j        |dz             D ]{}t          j	        
                    |          }||v r&t          d|z   t          t          j        f|t                              |t          j                  d          }|| |j        <   || S )NzWARNING: No examples dir foundzsuboptimal-behaviour)colorz/*.pyTest_)r)   rC   )r   ExampleMixinr(   unittestSkipTestlogr   r   r   r&   basenametyper   r   TestCasetime_rangesgetrC   rL   )r   example_dirignorefilenamebntcs         r
   _build_test_classesra   P   s   F'))-   19OPPPP #$$FIkG344 ! !Wh''<<bL!34)oob2D2OPP 
 
 !r{Ms    'AA__main__)__doc__r+   r   r   rB   rT   r$   testingr   r   r&   dirname__file__r   r   rO   rZ   rS   r   ra   itemskvlocalsrL   mainr   r   r
   <module>rl      sJ    
			 				    " " " " " "      7??8$$    %*2./ 
!4 !4 !4 !4 !4* !4 !4 !4F  2  !!''))  DAqFFHHQKKzIN r   