
    
_d                         d dl 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mZ d dl	m
Z
 d dlmZ d dlmZmZmZmZmZmZmZ ddlmZ d dlmZ d d	lmZ d d
lmZ  G d de      Z G d d      Z G d de      Zy)    N)DistutilsErrorDistutilsOptionError)log)
TestLoader)resource_listdirresource_existsnormalize_pathworking_setevaluate_markeradd_activation_listenerrequire   )metadata)Command)unique_everseen)	pass_nonec                       e Zd Zd ZddZy)ScanningLoaderc                 L    t        j                  |        t               | _        y N)r   __init__set_visitedselfs    9/usr/lib/python3/dist-packages/setuptools/command/test.pyr   zScanningLoader.__init__   s    D!    Nc                    || j                   v ry| j                   j                  |       g }|j                  t        j                  | |             t        |d      r|j                  |j                                t        |d      rt        |j                  d      D ]{  }|j                  d      r|dk7  r|j                  dz   |dd z   }n-t        |j                  |d	z         r|j                  dz   |z   }n\|j                  | j                  |             } t        |      d
k7  r| j                  |      S |d   S )a  Return a suite of all tests cases contained in the given module

        If the module is a package, load tests from all the modules in it.
        If the module has an ``additional_tests`` function, call it and add
        the return value to the tests.
        Nadditional_tests__path__ z.pyz__init__.py.z/__init__.py   r   )r   addappendr   loadTestsFromModulehasattrr   r   __name__endswithr   loadTestsFromNamelen
suiteClass)r   modulepatterntestsfile	submodules         r   r'   z"ScanningLoader.loadTestsFromModule   s    T]]"&!Z33D&AB6-.LL00236:&("= @=='DM,A &# 5Sb	 AI&v~8MN$*OOc$9D$@	 T33I>?@ u:???5))8Or   r   )r)   
__module____qualname__r   r'    r   r   r   r      s    r   r   c                       e Zd Zd ZddZy)NonDataPropertyc                     || _         y r   fget)r   r:   s     r   r   zNonDataProperty.__init__C   s	    	r   Nc                 ,    || S | j                  |      S r   r9   )r   objobjtypes      r   __get__zNonDataProperty.__get__F   s    ;Kyy~r   r   )r)   r3   r4   r   r>   r5   r   r   r7   r7   B   s    r   r7   c                       e Zd ZdZdZg dZd Zd Zed        Z	d Z
d Zej                  g fd	       Zeej                  d
               Zed        Zd Zd Zed        Zeed               Zy)testz.Command to run unit tests after in-place buildz0run unit tests after in-place build (deprecated)))ztest-module=mz$Run 'test_suite' in specified module)ztest-suite=sz9Run single test, case or suite (e.g. 'module.test_suite'))ztest-runner=rzTest runner to usec                 <    d | _         d | _        d | _        d | _        y r   )
test_suitetest_moduletest_loadertest_runnerr   s    r   initialize_optionsztest.initialize_options[   s!    r   c                    | j                   r| j                  rd}t        |      | j                   <| j                  | j                  j                   | _         n| j                  dz   | _         | j                  t        | j                  dd       | _        | j                  d| _        | j                  t        | j                  dd       | _        y y )Nz1You may specify a module or a suite, but not bothz.test_suiterG   z&setuptools.command.test:ScanningLoaderrH   )rE   rF   r   distributionrG   getattrrH   )r   msgs     r   finalize_optionsztest.finalize_optionsa   s    ??t//EC&s++??"'"&"3"3">">"&"2"2]"B#&t'8'8-ND#GD#&t'8'8-ND $r   c                 4    t        | j                               S r   )list
_test_argsr   s    r   	test_argsztest.test_argss   s    DOO%&&r   c              #      K   | j                   sd | j                  rd | j                   r| j                    y y w)Ndiscoverz	--verbose)rE   verboser   s    r   rQ   ztest._test_argsw   s6     <<??//! s   =?c                 \    | j                         5   |        ddd       y# 1 sw Y   yxY w)zI
        Backward compatibility for project_on_sys_path context.
        N)project_on_sys_path)r   funcs     r   with_project_on_sys_pathztest.with_project_on_sys_path   s*     %%' 	F	 	 	s   "+c              #     K   | j                  d       | j                  dd       | j                  d       | j                  d      }t        j                  d d  }t        j
                  j                         }	 t        |j                        }t        j                  j                  d|       t        j                          t        d        t        |j                  d|j                         | j!                  |g      5  d  d d d        |t        j                  d d  t        j
                  j#                          t        j
                  j%                  |       t        j                          y # 1 sw Y   nxY w# |t        j                  d d  t        j
                  j#                          t        j
                  j%                  |       t        j                          w xY ww)Negg_info	build_extr$   )inplacer   c                 "    | j                         S r   )activate)dists    r   <lambda>z*test.project_on_sys_path.<locals>.<lambda>   s     r   z==)run_commandreinitialize_commandget_finalized_commandsyspathmodulescopyr	   egg_baseinsertr
   r   r   r   egg_nameegg_versionpaths_on_pythonpathclearupdate)r   include_distsei_cmdold_pathold_modulesproject_paths         r   rW   ztest.project_on_sys_path   sY    $ 	!!+q!9%++J788A;kk&&(	#)&//:LHHOOA|,  "#$@A1C1CDE))<.9  #CHHQKKKKK{+  "  #CHHQKKKKK{+  "s9   A8G-;BF E8F A%G-8F=F A&G**G-c              #   h  K   t               }t        j                  j                  d|      }t        j                  j                  dd      }	 t        j                  j                  t        |             }t        d||g      }t        j                  j                  |      }|r|t        j                  d<   d ||u r!t        j                  j                  dd       y|t        j                  d<   y# ||u r!t        j                  j                  dd       w |t        j                  d<   w xY ww)z
        Add the indicated paths to the head of the PYTHONPATH environment
        variable so that subprocesses will also see the packages at
        these paths.

        Do this in a context that restores the value on exit.
        
PYTHONPATHr!   N)	objectosenvirongetpathsepjoinr   filterpop)pathsnothingorig_pythonpathcurrent_pythonpathprefixto_joinnew_paths          r   rm   ztest.paths_on_pythonpath   s      (**..w?ZZ^^L"=	;ZZ___U%;<FTF,>#?@Gzzw/H+3

<(')

|T2+:

<( ')

|T2+:

<(s   AD2A.C5 <9D25:D//D2c                    | j                  | j                        }| j                  | j                  xs g       }| j                  d | j                  j	                         D              }t        j                  |||      S )z
        Install the requirements indicated by self.distribution and
        return an iterable of the dists that were built.
        c              3   d   K   | ](  \  }}|j                  d       rt        |dd       r| * yw):r$   N)
startswithr   ).0kvs      r   	<genexpr>z%test.install_dists.<locals>.<genexpr>   s5      %
1||C _QqrU%; %
s   .0)fetch_build_eggsinstall_requirestests_requireextras_requireitems	itertoolschain)r`   ir_dtr_der_ds       r   install_distsztest.install_dists   sv     $$T%:%:;$$T%7%7%=2>$$ %
++113%
 

 tT400r   c                    | j                  dt        j                         | j                  | j                        }dj                  | j                        }| j                  r| j                  d|z         y | j                  d|z         t        t        j                  d      |      }| j                  |      5  | j                         5  | j                          d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)NzWARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox. zskipping "%s" (dry run)zrunning "%s"location)announcer   WARNr   rK   r|   _argvdry_runmapoperator
attrgetterrm   rW   	run_tests)r   installed_distscmdr   s       r   runztest.run   s     HH	
 ,,T->->?hhtzz"<<MM3c9:ns*+H''
3_E%%e, 	!))+ ! !	! 	!! !	! 	!s$   <C;C/C;/C8	4C;;Dc           	      Z   t        j                  d d | j                  | j                  | j                        | j                  | j
                        d      }|j                  j                         s:d|j                  z  }| j                  |t        j                         t        |      y )NF)
testLoader
testRunnerexitzTest failed: %s)unittestmainr   _resolve_as_eprG   rH   resultwasSuccessfulr   r   ERRORr   )r   r@   rM   s      r   r   ztest.run_tests   s    }}JJ**4+;+;<**4+;+;<
 {{((*#dkk1CMM#syy) %% +r   c                 "    dg| j                   z   S )Nr   )rR   r   s    r   r   z
test._argv   s    |dnn,,r   c                 X     t        j                  | dd      j                                S )zu
        Load the indicated attribute value, called, as a as if it were
        specified as an entry point.
        N)valuenamegroup)r   
EntryPointload)vals    r   r   ztest._resolve_as_ep   s(     Lx""4tDIIKMMr   N)r)   r3   r4   __doc__descriptionuser_optionsrI   rN   r7   rR   rQ   rY   
contextlibcontextmanagerrW   staticmethodrm   r   r   r   propertyr   r   r   r5   r   r   r@   r@   L   s    8DKL O$ ' '" 02 # #4 ;  ;0 1 1!.& - - N  Nr   r@   )rx   r   re   r   r   r   distutils.errorsr   r   	distutilsr   r   pkg_resourcesr   r   r	   r
   r   r   r   
_importlibr   
setuptoolsr    setuptools.extern.more_itertoolsr   "setuptools.extern.jaraco.functoolsr   r   r7   r@   r5   r   r   <module>r      sd    	  
    A     "  < 8$Z $P nN7 nNr   