509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
Ävhþ#  ã               @   sà   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 d dlmZmZ d dlmZmZmZmZmZmZmZmZmZ d dlmZ G d	d
„ d
eƒZG dd„ deƒZG dd„ deƒZ dS )é    N)ÚDistutilsErrorÚDistutilsOptionError)Úlog)Ú
TestLoader)Úsix)ÚmapÚfilter)	Úresource_listdirÚresource_existsÚnormalize_pathÚworking_setÚ_namespace_packagesÚevaluate_markerÚadd_activation_listenerÚrequireÚ
EntryPoint)ÚCommandc               @   s   e Zd Zdd„ Zddd„ZdS )ÚScanningLoaderc             C   s   t j| ƒ tƒ | _d S )N)r   Ú__init__ÚsetÚ_visited)Úself© r   ú/usr/lib/python3.6/test.pyr      s    
zScanningLoader.__init__Nc             C   sæ   || j krdS | j j|ƒ g }|jtj| |ƒƒ t|dƒrH|j|jƒ ƒ t|dƒrÄxpt|jdƒD ]`}|j	dƒrŽ|dkrŽ|jd |dd…  }n"t
|j|d	 ƒr`|jd | }nq`|j| j|ƒƒ q`W t|ƒd
krÚ| j|ƒS |d 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
   ZloadTestsFromNameÚlenZ
suiteClass)r   ÚmoduleÚpatternZtestsÚfileZ	submoduler   r   r   r#      s$    



z"ScanningLoader.loadTestsFromModule)N)r%   Ú
__module__Ú__qualname__r   r#   r   r   r   r   r      s   r   c               @   s   e Zd Zdd„ Zddd„ZdS )ÚNonDataPropertyc             C   s
   || _ d S )N)Úfget)r   r.   r   r   r   r   >   s    zNonDataProperty.__init__Nc             C   s   |d kr| S | j |ƒS )N)r.   )r   ÚobjZobjtyper   r   r   Ú__get__A   s    zNonDataProperty.__get__)N)r%   r+   r,   r   r0   r   r   r   r   r-   =   s   r-   c               @   s¢   e Zd ZdZdZd%d&d'gZdd„ Zdd„ Zedd„ ƒZ	dd„ Z
dd„ Zejg fdd„ƒZeejdd„ ƒƒZedd„ ƒZdd„ Zdd„ Zed d!„ ƒZed"d#„ ƒZd$S )(Útestz.Command to run unit tests after in-place buildz#run unit tests after in-place buildútest-module=Úmú$Run 'test_suite' in specified moduleútest-suite=Úsú9Run single test, case or suite (e.g. 'module.test_suite')útest-runner=ÚrúTest runner to usec             C   s   d | _ d | _d | _d | _d S )N)Ú
test_suiteÚtest_moduleÚtest_loaderÚtest_runner)r   r   r   r   Úinitialize_optionsS   s    ztest.initialize_optionsc             C   sŒ   | j r| jrd}t|ƒ‚| j d krD| jd kr8| jj | _ n| jd | _ | jd kr^t| jdd ƒ| _| jd krnd| _| jd krˆt| jdd ƒ| _d S )Nz1You may specify a module or a suite, but not bothz.test_suiter=   z&setuptools.command.test:ScanningLoaderr>   )r;   r<   r   Údistributionr=   Úgetattrr>   )r   Úmsgr   r   r   Úfinalize_optionsY   s    




ztest.finalize_optionsc             C   s   t | jƒ ƒS )N)ÚlistÚ
_test_args)r   r   r   r   Ú	test_argsl   s    ztest.test_argsc             c   s6   | j  rtjdkrdV  | jr$dV  | j r2| j V  d S )Né   é   Zdiscoverz	--verbose)rG   rH   )r;   ÚsysÚversion_infoÚverbose)r   r   r   r   rE   p   s    ztest._test_argsc          	   C   s   | j ƒ � |ƒ  W dQ R X dS )zI
        Backward compatibility for project_on_sys_path context.
        N)Úproject_on_sys_path)r   Úfuncr   r   r   Úwith_project_on_sys_pathx   s    
ztest.with_project_on_sys_pathc       	      c   sP  t jot| jddƒ}|rv| jddd� | jdƒ | jdƒ}t|jƒ}| jd|d� | jdƒ | jddd� | jdƒ n"| jdƒ | jdd	d� | jdƒ | jdƒ}t	j
d d … }t	jjƒ }zbt|jƒ}t	j
jd|ƒ tjƒ  td
d„ ƒ td|j|jf ƒ | j|gƒ� d V  W d Q R X W d |t	j
d d …< t	jjƒ  t	jj|ƒ tjƒ  X d S )NÚuse_2to3FZbuild_pyr   )ZinplaceZegg_info)Úegg_baseZ	build_extr   c             S   s   | j ƒ S )N)Zactivate)Údistr   r   r   Ú<lambda>£   s    z*test.project_on_sys_path.<locals>.<lambda>z%s==%s)r   ÚPY3rA   r@   Zreinitialize_commandZrun_commandZget_finalized_commandr   Z	build_librI   ÚpathÚmodulesÚcopyrP   Úinsertr   r   r   r   Zegg_nameZegg_versionÚpaths_on_pythonpathÚclearÚupdate)	r   Zinclude_distsZ	with_2to3Zbpy_cmdZ
build_pathZei_cmdZold_pathZold_modulesZproject_pathr   r   r   rL      s8    









ztest.project_on_sys_pathc             c   sŠ   t ƒ }tjjd|ƒ}tjjddƒ}z>tjj| ƒ}td||gƒ}tjj|ƒ}|rX|tjd< dV  W d||krztjjddƒ n
|tjd< X dS )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   Úpop)ÚpathsZnothingZorig_pythonpathZcurrent_pythonpathÚprefixZto_joinÚnew_pathr   r   r   rX   ­   s    


ztest.paths_on_pythonpathc             C   sD   | j | jƒ}| j | jpg ƒ}| j d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             s   s0   | ](\}}|j d ƒrt|dd… ƒr|V  qdS )ú:r   N)Ú
startswithr   )Ú.0ÚkÚvr   r   r   ú	<genexpr>Ð   s    z%test.install_dists.<locals>.<genexpr>)Zfetch_build_eggsZinstall_requiresZtests_requireZextras_requireÚitemsÚ	itertoolsÚchain)rQ   Zir_dZtr_dZer_dr   r   r   Úinstall_distsÇ   s
    ztest.install_distsc             C   s„   | j | jƒ}dj| jƒ}| jr0| jd| ƒ d S | jd| ƒ ttjdƒ|ƒ}| j	|ƒ�" | j
ƒ � | jƒ  W d Q R X W d Q R X d S )Nú zskipping "%s" (dry run)zrunning "%s"Úlocation)ro   r@   ra   Ú_argvZdry_runÚannouncer   ÚoperatorÚ
attrgetterrX   rL   Ú	run_tests)r   Zinstalled_distsÚcmdrc   r   r   r   ÚrunÕ   s    
ztest.runc             C   sØ   t jr‚t| jddƒr‚| jjdƒd }|tkr‚g }|tjkrD|j	|ƒ |d7 }x"tjD ]}|j
|ƒrT|j	|ƒ qTW tttjj|ƒƒ tjd d | j| j| jƒ| j| jƒdd�}|jjƒ sÔd|j }| j|tjƒ t|ƒ‚d S )NrO   Fr   r   )Z
testLoaderZ
testRunnerÚexitzTest failed: %s)r   rS   rA   r@   r;   Úsplitr   rI   rU   r"   rg   rD   r   Ú__delitem__ÚunittestÚmainrr   Ú_resolve_as_epr=   r>   ÚresultZwasSuccessfulrs   r   ZERRORr   )r   r(   Zdel_modulesÚnamer1   rB   r   r   r   rv   ä   s(    






ztest.run_testsc             C   s   dg| j  S )Nr|   )rF   )r   r   r   r   rr   ÿ   s    z
test._argvc             C   s$   | dkrdS t jd|  ƒ}|jƒ ƒ S )zu
        Load the indicated attribute value, called, as a as if it were
        specified as an entry point.
        Nzx=)r   ÚparseZresolve)ÚvalZparsedr   r   r   r~     s    ztest._resolve_as_epN)r2   r3   r4   )r5   r6   r7   )r8   r9   r:   )r%   r+   r,   Ú__doc__ÚdescriptionZuser_optionsr?   rC   r-   rF   rE   rN   Ú
contextlibÚcontextmanagerrL   ÚstaticmethodrX   ro   rx   rv   Úpropertyrr   r~   r   r   r   r   r1   G   s(    -r1   )!r]   rt   rI   r…   rm   r|   Zdistutils.errorsr   r   Z	distutilsr   r   Zsetuptools.externr   Zsetuptools.extern.six.movesr   r   Zpkg_resourcesr	   r
   r   r   r   r   r   r   r   Z
setuptoolsr   r   r\   r-   r1   r   r   r   r   Ú<module>   s   ,)
