3 (\E$@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZd d lmZeZ Gd d d e Z!Gd ddZ"GdddeZ#dS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)six)mapfilter) resource_listdirresource_existsnormalize_path working_set_namespace_packagesevaluate_markeradd_activation_listenerrequire EntryPoint)Command)_unique_everseenc@seZdZddZdddZdS)ScanningLoadercCstj|t|_dS)N)r__init__set_visited)selfrs/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-rm6ck8ia/setuptools/setuptools/command/test.pyrs zScanningLoader.__init__NcCs||jkrdS|jj|g}|jtj||t|drH|j|jt|drxpt|jdD]`}|j dr|dkr|jd|dd }n"t |j|d r`|jd|}nq`|j|j |q`Wt |d kr|j |S|d SdS) 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. Nadditional_tests__path__z.pyz __init__.py.z /__init__.pyrr)raddappendrloadTestsFromModulehasattrrr __name__endswithr ZloadTestsFromNamelenZ suiteClass)rmodulepatterntestsfile submodulerrrr$s$      z"ScanningLoader.loadTestsFromModule)N)r& __module__ __qualname__rr$rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dS)N)fget)rr1rrrrAszNonDataProperty.__init__NcCs|dkr |S|j|S)N)r1)robjZobjtyperrr__get__DszNonDataProperty.__get__)N)r&r.r/rr3rrrrr0@sr0c@seZdZdZdZd%d&d'gZd d ZddZeddZ ddZ ddZ e j gfddZee j ddZeddZddZddZed 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=s9Run single test, case or suite (e.g. 'module.test_suite') test-runner=rTest runner to usecCsd|_d|_d|_d|_dS)N) test_suite test_module test_loader test_runner)rrrrinitialize_optionsVsztest.initialize_optionscCs|jr|jrd}t||jdkrD|jdkr8|jj|_n |jd|_|jdkr^t|jdd|_|jdkrnd|_|jdkrt|jdd|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter@z&setuptools.command.test:ScanningLoaderrA)r>r?r distributionr@getattrrA)rmsgrrrfinalize_options\s        ztest.finalize_optionscCs t|jS)N)list _test_args)rrrr test_argsosztest.test_argsccs6|j rtjdkrdV|jr$dV|jr2|jVdS)NZdiscoverz --verbose)rJrK)r>sys version_infoverbose)rrrrrHss ztest._test_argsc Cs|j |WdQRXdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)rfuncrrrwith_project_on_sys_path{s ztest.with_project_on_sys_pathc csPtjot|jdd}|rv|jddd|jd|jd}t|j}|jd|d|jd|jddd|jdn"|jd|jdd d|jd|jd}t j dd}t j j }zbt|j }t j jd|tjtd d td |j|jf|j|g dVWdQRXWd|t j dd<t j jt j j|tjXdS) Nuse_2to3Fbuild_pyr)Zinplaceegg_info)egg_base build_extrcSs|jS)N)activate)distrrrsz*test.project_on_sys_path..z%s==%s)rPY3rDrCreinitialize_command run_commandget_finalized_commandr build_librLpathmodulescopyrUinsertr rrregg_nameZ egg_versionpaths_on_pythonpathclearupdate) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdold_pathZ old_modulesZ project_pathrrrrOs8             ztest.project_on_sys_pathc cst}tjjd|}tjjdd}zBtjjt|}td||g}tjj|}|r\|tjd<dVWd||kr~tjjddn |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) objectosenvirongetpathsepjoinrrpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrds    ztest.paths_on_pythonpathcCsD|j|j}|j|jpg}|jdd|jjD}tj|||S)z Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css0|](\}}|jdrt|ddr|VqdS):rN) startswithr).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rXZir_dZtr_dZer_drrr install_distss  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) r|rCrn_argvdry_runannounceroperator attrgetterrdrO run_tests)rZinstalled_distscmdrprrrruns    ztest.runcCstjrt|jddr|jjdd}|tkrg}|tjkrD|j ||d7}x"tjD]}|j |rT|j |qTWt t tjj |tjdd|j|j|j|j|jdd}|jjsd|j}|j|tjt|dS)NrRFrr)Z testLoaderZ testRunnerexitzTest failed: %s)rrZrDrCr>splitr rLr`r#rtrGr __delitem__unittestmainr_resolve_as_epr@rAresultZ wasSuccessfulrrERRORr)rr)Z del_modulesnamer4rErrrrs(        ztest.run_testscCs dg|jS)Nr)rI)rrrrrsz test._argvcCs$|dkr dStjd|}|jS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseresolve)valparsedrrrrsztest._resolve_as_epN)r5r6r7)r8r9r:)r;r<r=)r&r.r/__doc__ description user_optionsrBrFr0rIrHrQ contextlibcontextmanagerrO staticmethodrdr|rrpropertyrrrrrrr4Js( -  r4)$rjrrLrrzrdistutils.errorsrr distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrr pkg_resourcesr r r r r rrrr setuptoolsrrSrtype __metaclass__rr0r4rrrrs"   ,  )