a [dg$@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z mZmZmZmZmZmZmZmZddlmZddlmZGd d d e ZGd d d ZGd ddeZdS)N)DistutilsErrorDistutilsOptionError)log) TestLoader) resource_listdirresource_existsnormalize_path working_set_namespace_packagesevaluate_markeradd_activation_listenerrequire EntryPoint)Command)_unique_everseenc@seZdZddZdddZdS)ScanningLoadercCst|t|_dSN)r__init__set_visitedselfrA/usr/local/lib/python3.9/site-packages/setuptools/command/test.pyrs zScanningLoader.__init__NcCs||jvrdS|j|g}|t||t|drH||t|drt|jdD]`}| dr|dkr|jd|dd}n"t |j|dr^|jd|}nq^|| |q^t |d kr| |S|d SdS) Nadditional_tests__path__z.pyz __init__.py.z /__init__.pyrr)raddappendrloadTestsFromModulehasattrrr__name__endswithrZloadTestsFromNamelenZ suiteClass)rmodulepatternZtestsfileZ submodulerrrr"s$      z"ScanningLoader.loadTestsFromModule)N)r$ __module__ __qualname__rr"rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dSrfget)rr.rrrr<szNonDataProperty.__init__NcCs|dur |S||Srr-)robjZobjtyperrr__get__?szNonDataProperty.__get__)N)r$r*r+rr0rrrrr,;sr,c@seZdZdZgdZddZddZeddZd d Z d d Z e j gfd dZ ee j ddZeddZddZddZeddZeddZdS)testz0run 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_optionsQsztest.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_suiter7z&setuptools.command.test:ScanningLoaderr8)r5r6r distributionr7getattrr8)rmsgrrrfinalize_optionsWs        ztest.finalize_optionscCs t|Sr)list _test_argsrrrr test_argsjsztest.test_argsccs4|jstjdkrdV|jr"dV|jr0|jVdS)N)Zdiscoverz --verbose)r5sys version_infoverboserrrrr?ns ztest._test_argscCs2||Wdn1s$0YdSr)project_on_sys_path)rfuncrrrwith_project_on_sys_pathvs ztest.with_project_on_sys_pathc cst|jdd}|rp|jddd|d|d}t|j}|jd|d|d|jddd|dn"|d|jdd d|d|d}tjdd}tj }zt|j }tj d|t td d td |j|jf||gdVWdn1s 0YW|tjdd<tj tj |t n.|tjdd<tj tj |t 0dS) Nuse_2to3Fbuild_pyr)ZinplaceZegg_info)egg_baseZ build_extrcSs|Sr)Zactivate)distrrrz*test.project_on_sys_path..z%s==%s)r;r:Zreinitialize_commandZ run_commandZget_finalized_commandrZ build_librCpathmodulescopyrKinsertr rr r Zegg_nameZ egg_versionpaths_on_pythonpathclearupdate) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathrrrrF}s@           (     ztest.project_on_sys_pathc cst}tjd|}tjdd}zdtjt|}td||g}tj|}|r\|tjd<dVW||ur|tjddq|tjd<n$||urtjddn |tjd<0dS)NZ PYTHONPATHr) objectosenvirongetpathsepjoinrfilterpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrSs    ztest.paths_on_pythonpathcCsD||j}||jpg}|dd|jD}t|||S)Ncss0|](\}}|drt|ddr|VqdS):rN) startswithr ).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rLZir_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)announcerWARNrjr:r[_argvdry_runmapoperator attrgetterrSrF run_tests)rZinstalled_distscmdr^rrrruns    ztest.runcCst|jddrx|jdd}|tvrxg}|tjvr>|||d7}tjD]}||rL||qLt t tjj |t j dd|j||j||jdd}|jsd|j}||tjt|dS)NrIFrr)Z testLoaderZ testRunnerexitzTest failed: %s)r;r:r5splitr rCrPr!rbr>rq __delitem__unittestmainro_resolve_as_epr7r8resultZ wasSuccessfulrmrERRORr)rr'Z del_modulesnamer1r<rrrrts*         ztest.run_testscCs dg|jS)Nrz)r@rrrrrosz test._argvcCs$|dur dStd|}|S)Nzx=)rparseresolve)valparsedrrrr| sztest._resolve_as_epN)r$r*r+ descriptionZ user_optionsr9r=r,r@r?rH contextlibcontextmanagerrF staticmethodrSrjrvrtpropertyror|rrrrr1Es* -   r1)rWrrrCrrhrzZdistutils.errorsrrZ distutilsrrZ pkg_resourcesrrrr r r r r rZ setuptoolsrrJrrr,r1rrrrs  ,  )