U âQab‚%ã@sîddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZd d lmZeZ Gd d „d e ƒZ!Gd d„dƒZ"Gdd„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)ÚCommandé)Ú_unique_everseenc@seZdZdd„Zddd„ZdS)ÚScanningLoadercCst |¡tƒ|_dS©N)rÚ__init__ÚsetÚ_visited©Úself©rú;/usr/lib/python3.8/site-packages/setuptools/command/test.pyrs zScanningLoader.__init__NcCsâ||jkrdS|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__.pyrr)rÚaddÚappendrÚloadTestsFromModuleÚhasattrrr Ú__name__Úendswithr ZloadTestsFromNameÚlenZ suiteClass)rÚmoduleÚpatternZtestsÚfileZ submodulerrrr%s$      z"ScanningLoader.loadTestsFromModule)N)r'Ú __module__Ú __qualname__rr%rrrrrsrc@seZdZdd„Zddd„ZdS)ÚNonDataPropertycCs ||_dSr©Úfget)rr1rrrrAszNonDataProperty.__init__NcCs|dkr |S| |¡Srr0)rÚobjZobjtyperrrÚ__get__DszNonDataProperty.__get__)N)r'r-r.rr3rrrrr/@sr/c@s¢eZdZdZdZdddgZdd„Zdd „Zed d „ƒZ d d „Z dd„Z e j gfdd„ƒZee j dd„ƒƒZedd„ƒZdd„Zdd„Zedd„ƒZedd„ƒ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_optionsVsztest.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;)r8r9rÚ distributionr:Úgetattrr;)rÚmsgrrrÚfinalize_options\s        ztest.finalize_optionscCs t| ¡ƒSr)ÚlistÚ _test_argsrrrrÚ test_argsosztest.test_argsccs4|jstjdkrdV|jr"dV|jr0|jVdS)N)ééZdiscoverz --verbose)r8ÚsysÚ version_infoÚverboserrrrrBss ztest._test_argsc Cs| ¡� |ƒW5QRXdS)zI Backward compatibility for project_on_sys_path context. N)Úproject_on_sys_path)rÚfuncrrrÚwith_project_on_sys_path{s ztest.with_project_on_sys_pathc csPtjot|jddƒ}|rv|jddd�| d¡| d¡}t|jƒ}|jd|d�| d¡|jddd�| d¡n"| d¡|jdd d�| d¡| d¡}t j dd…}t j   ¡}zbt|jƒ}t j  d|¡t ¡td d „ƒtd |j|jfƒ| |g¡� dVW5QRXW5|t j dd…<t j   ¡t j  |¡t ¡XdS) NÚuse_2to3FÚbuild_pyr)ZinplaceZegg_info)Úegg_baseZ build_extrcSs| ¡Sr)Zactivate)ÚdistrrrÚ¦óz*test.project_on_sys_path..z%s==%s)rÚPY3r>r=Zreinitialize_commandZ run_commandZget_finalized_commandr Z build_librFÚpathÚmodulesÚcopyÚclearÚupdater rrNÚinsertrrZegg_nameZ egg_versionÚpaths_on_pythonpath) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathrrrrI‚s8             ztest.project_on_sys_pathc csŽtƒ}tj d|¡}tj dd¡}zBtj t|ƒ¡}td||gƒ}tj |¡}|r\|tjd<dVW5||kr~tj dd¡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. Z PYTHONPATHr N) ÚobjectÚosÚenvironÚgetÚpopÚpathsepÚjoinrr)ÚpathsZnothingZorig_pythonpathZcurrent_pythonpathÚprefixZto_joinÚnew_pathrrrrY°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)ú:rN)Ú startswithr)Ú.0ÚkÚvrrrÚ Òs ÿz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireÚitemsÚ itertoolsÚchain)rOZir_dZtr_dZer_drrrÚ install_distsÊs   ÿztest.install_distsc Cs’| dtj¡| |j¡}d |j¡}|jr>| d|¡dS| d|¡tt   d¡|ƒ}|  |¡�"|  ¡�|  ¡W5QRXW5QRXdS)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)ÚannouncerZWARNrmr=r`Ú_argvZdry_runrÚoperatorÚ attrgetterrYrIÚ run_tests)rZinstalled_distsÚcmdrarrrÚrunØsû    ztest.runcCsÔtjr~t|jddƒr~|j d¡d}|tkr~g}|tjkrD|  |¡|d7}tjD]}|  |¡rR|  |¡qRt t tjj |ƒƒtjdd|j| |j¡| |j¡dd�}|j ¡sÐd|j}| |tj¡t|ƒ‚dS)NrLFr!r)Z testLoaderZ testRunnerÚexitzTest failed: %s)rrRr>r=r8Úsplitr rFrTr$rerArÚ __delitem__ÚunittestÚmainrqÚ_resolve_as_epr:r;ÚresultZ wasSuccessfulrprZERRORr)rr*Z del_modulesÚnamer4r?rrrrtïs.       ü  ztest.run_testscCs dg|jS)Nrz)rCrrrrrq sz test._argvcCs$|dkr dSt d|¡}| ¡ƒS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rÚparseZresolve)ÚvalZparsedrrrr|sztest._resolve_as_epN)r'r-r.Ú__doc__Ú descriptionZ user_optionsr<r@r/rCrBrKÚ contextlibÚcontextmanagerrIÚ staticmethodrYrmrvrtÚpropertyrqr|rrrrr4Js2ü -   r4)$r[rrrFrƒrkrzZdistutils.errorsrrZ distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesr r r r r rrrrZ setuptoolsrrMrÚtypeZ __metaclass__rr/r4rrrrÚs"   ,  )