a oe@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z mZmZmZmZmZmZddlmZddlmZdd lmZdd lmZGd d d e ZGd ddZGdddeZdS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)resource_listdirresource_existsnormalize_path working_setevaluate_markeradd_activation_listenerrequire)metadata)Command)unique_everseen) pass_nonec@seZdZddZdddZdS)ScanningLoadercCst|t|_dSN)r__init__set_visitedselfr8C:\Program Files\Certbot\pkgs\setuptools\command\test.pyrs zScanningLoader.__init__NcCs||jvrdS|j|g}|t||t|drH||t|drt|jdD]`}| dr|dkr|jd|dd}n"t |j|d r^|jd|}nq^|| |q^t |d kr| |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__.pyr)raddappendrloadTestsFromModulehasattrrr__name__endswithrZloadTestsFromNamelenZ suiteClass)rmodulepatternZtestsfileZ submodulerrrr#s$      z"ScanningLoader.loadTestsFromModule)N)r% __module__ __qualname__rr#rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dSrfget)rr/rrrrCszNonDataProperty.__init__NcCs|dur |S||Srr.)robjZobjtyperrr__get__FszNonDataProperty.__get__)N)r%r+r,rr1rrrrr-Bsr-c@seZdZdZdZgdZddZddZedd Z d d Z d d Z e j gfddZee j ddZeddZddZddZeddZeeddZdS)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=rzTest runner to usecCsd|_d|_d|_d|_dSr) test_suite test_module test_loader test_runnerrrrrinitialize_options[sztest.initialize_optionscCs|jr|jrd}t||jdurD|jdur8|jj|_n |jd|_|jdur^t|jdd|_|jdurnd|_|jdurt|jdd|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter8z&setuptools.command.test:ScanningLoaderr9)r6r7r distributionr8getattrr9)rmsgrrrfinalize_optionsas        ztest.finalize_optionscCs t|Sr)list _test_argsrrrr test_argsssztest.test_argsccs*|js dV|jrdV|jr&|jVdS)NZdiscoverz --verbose)r6verboserrrrr@ws ztest._test_argscCs2||Wdn1s$0YdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)rfuncrrrwith_project_on_sys_paths ztest.with_project_on_sys_pathc cs|d|jddd|d|d}tjdd}tj}zt|j}tj d|t t ddt d|j|jf||gdVWdn1s0YW|tjdd<tjtj|t n.|tjdd<tjtj|t 0dS) NZegg_infoZ build_extr )ZinplacercSs|Sr)Zactivate)distrrrz*test.project_on_sys_path..z%s==%s)Z run_commandZreinitialize_commandZget_finalized_commandsyspathmodulescopyrZegg_baseinsertr rr r Zegg_nameZ egg_versionpaths_on_pythonpathclearupdate)rZ include_distsZei_cmdold_pathZ old_modulesZ project_pathrrrrCs,      &     ztest.project_on_sys_pathc cst}tjd|}tjdd}zdtjt|}td||g}tj|}|r\|tjd<dVW||ur|tjddq|tjd<n$||urtjddn |tjd<0dS)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. Z PYTHONPATHrN) objectosenvirongetpathsepjoinrfilterpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrNs    ztest.paths_on_pythonpathcCsD||j}||jpg}|dd|jD}t|||S)z Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css0|](\}}|drt|ddr|VqdS):r N) startswithr ).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rFZir_dZtr_dZer_drrr install_distss   ztest.install_distsc Cs|dtj||j}d|j}|jr>|d|dS|d|tt d|}| |@| | Wdn1s0YWdn1s0YdS)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. zskipping "%s" (dry run)z running "%s"location)announcerZWARNrfr;rW_argvdry_runmapoperator attrgetterrNrC run_tests)rZinstalled_distscmdrZrrrruns    ztest.runcCsVtjdd|j||j||jdd}|jsRd|j}||t j t |dS)NF)Z testLoaderZ testRunnerexitzTest failed: %s) unittestmainrj_resolve_as_epr8r9resultZ wasSuccessfulrirZERRORr)rr2r=rrrros    ztest.run_testscCs dg|jS)Nrs)rArrrrrjsz test._argvcCstj|dddS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. N)valuenamegroup)rZ EntryPointload)valrrrrusztest._resolve_as_epN)r%r+r,__doc__ descriptionZ user_optionsr:r>r-rAr@rE contextlibcontextmanagerrC staticmethodrNrfrqropropertyrjrrurrrrr2Ls.     r2)rSrmrIr~rdrsZdistutils.errorsrrZ distutilsrrZ pkg_resourcesrrrr r r r Z _importlibrZ setuptoolsrZ setuptools.extern.more_itertoolsrZ"setuptools.extern.jaraco.functoolsrrr-r2rrrrs   $    (