a „oe¥ã@sÞddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z mZmZmZmZmZmZddlmZddlmZdd lmZdd lmZGd d „d e ƒZGd d„dƒZGdd„deƒZdS)é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@seZdZdd„Zddd„ZdS)ÚScanningLoadercCst |¡tƒ|_dS©N)rÚ__init__ÚsetÚ_visited©Úself©rú8C:\Program Files\Certbot\pkgs\setuptools\command\test.pyrs zScanningLoader.__init__NcCsâ||jvrdS|j |¡g}| t ||¡¡t|dƒrH| | ¡¡t|dƒrÀt|jdƒD]`}|  d¡rŒ|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. NÚadditional_testsÚ__path__Úz.pyz __init__.pyÚ.éýÿÿÿz /__init__.pyér)rÚaddÚappendrÚloadTestsFromModuleÚhasattrrrÚ__name__ÚendswithrZloadTestsFromNameÚlenZ suiteClass)rÚmoduleÚpatternZtestsÚfileZ submodulerrrr#s$      z"ScanningLoader.loadTestsFromModule)N)r%Ú __module__Ú __qualname__rr#rrrrrsrc@seZdZdd„Zddd„ZdS)ÚNonDataPropertycCs ||_dSr©Úfget)rr/rrrrCszNonDataProperty.__init__NcCs|dur |S| |¡Srr.)rÚobjZobjtyperrrÚ__get__FszNonDataProperty.__get__)N)r%r+r,rr1rrrrr-Bsr-c@s¤eZdZdZdZgd¢Zdd„Zdd„Zedd „ƒZ d d „Z d d „Z e j gfdd„ƒZee j dd„ƒƒZedd„ƒZdd„Zdd„Zedd„ƒZeedd„ƒƒZdS)Ú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_runnerrrrrÚinitialize_options[sztest.initialize_optionscCsŒ|jr|jrd}t|ƒ‚|jdurD|jdur8|jj|_n |jd|_|jdur^t|jddƒ|_|jdurnd|_|jdurˆt|jddƒ|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter8z&setuptools.command.test:ScanningLoaderr9)r6r7rÚ distributionr8Úgetattrr9)rÚmsgrrrÚfinalize_optionsas        ztest.finalize_optionscCs t| ¡ƒSr)ÚlistÚ _test_argsrrrrÚ test_argsssztest.test_argsccs*|js dV|jrdV|jr&|jVdS)NZdiscoverz --verbose)r6Úverboserrrrr@ws ztest._test_argscCs2| ¡�|ƒWdƒn1s$0YdS)zI Backward compatibility for project_on_sys_path context. N)Úproject_on_sys_path)rÚfuncrrrÚwith_project_on_sys_paths ztest.with_project_on_sys_pathc cs| d¡|jddd�| d¡| d¡}tjdd…}tj ¡}z¢t|jƒ}tj  d|¡t   ¡t dd„ƒt d|j|jfƒ| |g¡�dVWdƒn1s®0YW|tjdd…<tj ¡tj |¡t   ¡n.|tjdd…<tj ¡tj |¡t   ¡0dS) NZegg_infoZ build_extr )ZinplacercSs| ¡Sr)Zactivate)ÚdistrrrÚ—óz*test.project_on_sys_path..z%s==%s)Z run_commandZreinitialize_commandZget_finalized_commandÚsysÚpathÚmodulesÚcopyrZegg_baseÚinsertr rr r Zegg_nameZ egg_versionÚpaths_on_pythonpathÚclearÚupdate)rZ include_distsZei_cmdÚold_pathZ old_modulesZ project_pathrrrrC†s,      &   ý  ztest.project_on_sys_pathc cs°tƒ}tj d|¡}tj dd¡}zdtj t|ƒ¡}td||gƒ}tj |¡}|r\|tjd<dVW||ur|tj dd¡q¬|tjd<n$||ur tj dd¡n |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) ÚobjectÚosÚenvironÚgetÚpathsepÚjoinrÚfilterÚpop)ÚpathsZnothingZorig_pythonpathZcurrent_pythonpathÚprefixZto_joinÚnew_pathrrrrN¡s    ýztest.paths_on_pythonpathcCsD| |j¡}| |jpg¡}| dd„|j ¡Dƒ¡}t |||¡S)z† Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css0|](\}}| d¡rt|dd…ƒr|VqdS)ú:r N)Ú startswithr )Ú.0ÚkÚvrrrÚ Ãsþz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireÚitemsÚ itertoolsÚchain)rFZir_dZtr_dZer_drrrÚ install_dists»s   þztest.install_distsc Csº| dtj¡| |j¡}d |j¡}|jr>| d|¡dS| d|¡tt   d¡|ƒ}|  |¡�@|  ¡�|  ¡Wdƒn1sŽ0YWdƒn1s¬0YdS)Nz»WARNING: 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Ú_argvÚdry_runÚmapÚoperatorÚ attrgetterrNrCÚ run_tests)rZinstalled_distsÚcmdrZrrrÚrunÊsû    ztest.runcCsVtjdd|j| |j¡| |j¡dd�}|j ¡sRd|j}| |t j ¡t |ƒ‚dS)NF)Z testLoaderZ testRunnerÚexitzTest failed: %s) ÚunittestÚmainrjÚ_resolve_as_epr8r9ÚresultZ wasSuccessfulrirZERRORr)rr2r=rrrroás  ú  ztest.run_testscCs dg|jS)Nrs)rArrrrrjïsz test._argvcCstj|ddd� ¡ƒS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. N)ÚvalueÚnameÚgroup)rZ EntryPointÚload)Úvalrrrruósztest._resolve_as_epN)r%r+r,Ú__doc__Ú descriptionZ user_optionsr:r>r-rAr@rEÚ contextlibÚcontextmanagerrCÚ staticmethodrNrfrqroÚpropertyrjrrurrrrr2Ls.     r2)rSrmrIr~rdrsZdistutils.errorsrrZ distutilsrrZ pkg_resourcesrrrr r r r Z _importlibrZ setuptoolsrZ setuptools.extern.more_itertoolsrZ"setuptools.extern.jaraco.functoolsrrr-r2rrrrÚs   $    (