3

Q'ícþ#ã@sàddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
ddlmZddlm
Z
ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZGd	d
„d
eƒZGdd„deƒZGd
d„deƒZ dS)é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@seZdZdd„Zddd„ZdS)ÚScanningLoadercCstj|ƒtƒ|_dS)N)rÚ__init__ÚsetÚ_visited)Úself©rú=/tmp/pip-build-l_bcah40/setuptools/setuptools/command/test.pyrs
zScanningLoader.__init__NcCsæ||jkrdS|jj|ƒg}|jtj||ƒƒt|dƒrH|j|jƒƒt|dƒrÄxpt|jdƒD]`}|j	dƒrŽ|dkrŽ|jd|dd…}n"t
|j|d	ƒr`|jd|}nq`|j|j|ƒƒq`Wt|ƒd
krÚ|j
|ƒS|dSdS)
aReturn 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Úhasattrrr	Ú__name__Úendswithr
ZloadTestsFromNameÚlenZ
suiteClass)rÚmoduleÚpatternÚtestsÚfileÚ	submodulerrrr#s$



z"ScanningLoader.loadTestsFromModule)N)r%Ú
__module__Ú__qualname__rr#rrrrrsrc@seZdZdd„Zddd„ZdS)ÚNonDataPropertycCs
||_dS)N)Úfget)rr0rrrr>szNonDataProperty.__init__NcCs|dkr|S|j|ƒS)N)r0)rÚobjZobjtyperrrÚ__get__AszNonDataProperty.__get__)N)r%r-r.rr2rrrrr/=sr/c@s¢eZdZdZdZd%d&d'gZdd
„Zdd„Zedd„ƒZ	dd„Z
dd„Zej
gfdd„ƒZeej
dd„ƒƒZedd„ƒZdd„Zdd„Zed d!„ƒZed"d#„ƒZd$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 usecCsd|_d|_d|_d|_dS)N)Ú
test_suiteÚtest_moduleÚtest_loaderÚtest_runner)rrrrÚinitialize_optionsSsztest.initialize_optionscCsŒ|jr|jrd}t|ƒ‚|jdkrD|jdkr8|jj|_n|jd|_|jdkr^t|jddƒ|_|jdkrnd|_|jdkrˆt|jddƒ|_dS)Nz1You may specify a module or a suite, but not bothz.test_suiter?z&setuptools.command.test:ScanningLoaderr@)r=r>rÚdistributionr?Úgetattrr@)rÚmsgrrrÚfinalize_optionsYs




ztest.finalize_optionscCst|jƒƒS)N)ÚlistÚ
_test_args)rrrrÚ	test_argslsztest.test_argsccs6|jrtjdkrdV|jr$dV|jr2|jVdS)NééZdiscoverz	--verbose)rIrJ)r=ÚsysÚversion_infoÚverbose)rrrrrGpsztest._test_argsc	Cs|jƒ|ƒWdQRXdS)zI
        Backward compatibility for project_on_sys_path context.
        N)Úproject_on_sys_path)rÚfuncrrrÚwith_project_on_sys_pathxs
ztest.with_project_on_sys_pathc	csPtjot|jddƒ}|rv|jddd|jdƒ|jdƒ}t|jƒ}|jd|d|jdƒ|jddd|jdƒn"|jdƒ|jdd	d|jdƒ|jdƒ}t	j
dd…}t	jjƒ}zbt|j
ƒ}t	j
jd|ƒtjƒtd
d„ƒtd|j|jfƒ|j|gƒdVWdQRXWd|t	j
dd…<t	jjƒt	jj|ƒtjƒXdS)
NÚuse_2to3FÚbuild_pyr)ZinplaceÚegg_info)Úegg_baseÚ	build_extrcSs|jƒS)N)Úactivate)ÚdistrrrÚ<lambda>£sz*test.project_on_sys_path.<locals>.<lambda>z%s==%s)rÚPY3rCrBÚreinitialize_commandÚrun_commandÚget_finalized_commandrÚ	build_librKÚpathÚmodulesÚcopyrTÚinsertrrrrÚegg_nameZegg_versionÚpaths_on_pythonpathÚclearÚupdate)	rZ
include_distsZ	with_2to3Zbpy_cmdZ
build_pathZei_cmdZold_pathZold_modulesZproject_pathrrrrNs8









ztest.project_on_sys_pathccsŠtƒ}tjjd|ƒ}tjjddƒ}z>tjj|ƒ}td||gƒ}tjj|ƒ}|rX|tjd<dVWd||krztjjddƒn
|tjd<XdS)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.
        Ú
PYTHONPATHrN)ÚobjectÚosÚenvironÚgetÚpathsepÚjoinrÚpop)ÚpathsZnothingZorig_pythonpathZcurrent_pythonpathÚprefixZto_joinÚnew_pathrrrrc­s


ztest.paths_on_pythonpathcCsD|j|jƒ}|j|jpgƒ}|jdd„|jjƒDƒƒ}tj|||ƒS)z†
        Install the requirements indicated by self.distribution and
        return an iterable of the dists that were built.
        css0|](\}}|jdƒrt|dd…ƒr|VqdS)ú:rN)Ú
startswithr)Ú.0ÚkÚvrrrú	<genexpr>Ðsz%test.install_dists.<locals>.<genexpr>)Zfetch_build_eggsZinstall_requiresZ
tests_requireZextras_requireÚitemsÚ	itertoolsÚchain)rWZir_dZtr_dZer_drrrÚ
install_distsÇs
ztest.install_distscCs„|j|jƒ}dj|jƒ}|jr0|jd|ƒdS|jd|ƒttjdƒ|ƒ}|j	|ƒ"|j
ƒ|jƒWdQRXWdQRXdS)Nú zskipping "%s" (dry run)zrunning "%s"Úlocation)rzrBrlÚ_argvÚdry_runÚannouncerÚoperatorÚ
attrgetterrcrNÚ	run_tests)rÚinstalled_distsÚcmdrnrrrÚrunÕs
ztest.runcCsØtjr‚t|jddƒr‚|jjdƒd}|tkr‚g}|tjkrD|j	|ƒ|d7}x"tjD]}|j
|ƒrT|j	|ƒqTWtttjj
|ƒƒtjdd|j|j|jƒ|j|jƒdd}|jjƒsÔd|j}|j|tjƒt|ƒ‚dS)NrQFrr)Z
testLoaderZ
testRunnerÚexitzTest failed: %s)rrYrCrBr=Úsplitr
rKr_r"rrrFrÚ__delitem__ÚunittestÚmainr}Ú_resolve_as_epr?r@ÚresultZ
wasSuccessfulrrÚERRORr)rr(Zdel_modulesÚnamer3rDrrrr‚äs(






ztest.run_testscCsdg|jS)Nr‰)rH)rrrrr}ÿsz
test._argvcCs$|dkrdStjd|ƒ}|jƒƒS)zu
        Load the indicated attribute value, called, as a as if it were
        specified as an entry point.
        Nzx=)rÚparseÚresolve)ÚvalÚparsedrrrr‹sztest._resolve_as_epN)r4r5r6)r7r8r9)r:r;r<)r%r-r.Ú__doc__ÚdescriptionÚuser_optionsrArEr/rHrGrPÚ
contextlibÚcontextmanagerrNÚstaticmethodrcrzr…r‚Úpropertyr}r‹rrrrr3Gs(-r3)!rhr€rKr–rxr‰Zdistutils.errorsrrÚ	distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrrÚ
pkg_resourcesr	r
rrr
rrrrÚ
setuptoolsrrrgr/r3rrrrÚ<module>s,)