
    <|h                     H   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                  j                  e      Zd ZdZdded   fdZ G d	 d
e	j"                        Zd Z e       j)                         D ]  \  ZZe e       e<    edk(  r ej2                          yy)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                  v   t        j                         } 	 t        j                  t               t	        j                  d      D cg c]  }|dd  	 }}t
        j                  r!t
        j                  r|j                  d       t        j                  |        |S c c}w # t        j                  |        w xY w)Nztest__example_*.py   processes.py)	osgetcwdchdirthis_dirglob	greentestPYPYRUNNING_ON_APPVEYORappend)old_dirxresults      Z/var/www/html/test/engine/venv/lib/python3.12/site-packages/gevent/tests/test__examples.py_find_files_to_ignorer      s    iikG	
"&)),@"ABQ!BC&BB>>i;; MM.)
M C 	s   0B! B3B! B! !B8)   
   )r      )zconcurrent_download.pyr   c                        e Zd ZeZdZd Zd Zy)_AbstractTestMixinNc                    ddl m} t        t        j                  j                  | j                  | j                        d      5 }|j                         }d d d        t        j                  dt        j                        }t        j                  |      }|D ]6  }||j                  d      |j                  d       }|j                  |       8 y # 1 sw Y   xY w)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    , "'',,txx6< 	 vvxH	  **FU;;w9% 	4Eekk!nUYYq\:F++F3	4	  	 s   CCc                 8   | j                          t        j                         }| j                  \  }}|dddddid| _        | j	                         s| j                  d| j                  z          y t        j                         |z
  }| j                  ||       y )NTGEVENT_DEBUGerror)timeoutquietbuffer_outputnestedsetenvzFailed example: )r4   time
time_rangestart_kwargsrun_examplefailr$   assertGreaterEqual)r-   r*   min_timemax_timetooks        r   	test_runsz_AbstractTestMixin.test_runs>   s    		!__(!%w/
 !II(4<<7899;&D##D(3    )__name__
__module____qualname__default_time_ranger>   r$   r4   rF    rG   r   r   r   -   s    #JG44rG   r   c            
         i } 	 t        j                         j                  }t               }t        j                  |dz         D ]~  }t        j                  j                  |      }||v r't        d|z   t        t        j                  f|t        j!                  |t        j"                        d      }|| |j$                  <    | S # t        j                  $ r t        j
                  dd       | cY S w xY w)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>   rH   )r   example_dirignorefilenamebntcs         r   _build_test_classesr^   P   s    F'')--
 #$FIIkG34 !WWh'<bL!3!34)oob2D2O2OP
 !r{{! M'  19OPs   C ,C65C6__main__)__doc__r&   r   r   r=   rQ   r   testingr   r   r!   dirname__file__r
   r   rK   rW   rP   r   r^   itemskvlocalsrH   mainrL   rG   r   <module>ri      s    
 	    " 77??8$  %*2./
!4** !4F2  !'') DAqFHQK zINN rG   