a c%@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)ScanningLoadercCst|t|_dSN)r__init__set_visitedselfrd/workspaces/shunt/resources/test-fastapi/venv/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|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__.pyrr)raddappendrloadTestsFromModulehasattrrr __name__endswithr ZloadTestsFromNamelenZ suiteClass)rmodulepatterntestsfile submodulerrrr%s$      z"ScanningLoader.loadTestsFromModule)N)r' __module__ __qualname__rr%rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dSrfget)rr3rrrrAszNonDataProperty.__init__NcCs|dur |S||Srr2)robjZobjtyperrr__get__DszNonDataProperty.__get__)N)r'r/r0rr5rrrrr1@sr1c@seZdZdZdZgdZddZddZedd Z d d Z d d Z e j gfddZee j ddZeddZddZddZeddZeddZdS)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_optionsVsztest.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_suiter<z&setuptools.command.test:ScanningLoaderr=)r:r;r distributionr<getattrr=)rmsgrrrfinalize_options\s        ztest.finalize_optionscCs t|Sr)list _test_argsrrrr test_argsosztest.test_argsccs4|jstjdkrdV|jr"dV|jr0|jVdS)N)Zdiscoverz --verbose)r:sys version_infoverboserrrrrDss ztest._test_argscCs2||Wdn1s$0YdS)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 cstj ot|jdd}|rx|jddd|d|d}t|j}|jd|d|d|jddd|dn"|d|jdd d|d|d}t j dd}t j }zt|j }t j d|ttd d td |j|jf||gdVWdn1s(0YW|t j dd<t j t j |tn.|t j dd<t j t j |t0dS) Nuse_2to3Fbuild_pyr)Zinplaceegg_info)egg_base build_extrcSs|Sr)activate)distrrrz*test.project_on_sys_path..z%s==%s)rPY2r@r?reinitialize_command run_commandget_finalized_commandr build_librHpathmodulescopyrQinsertr rrregg_nameZ egg_versionpaths_on_pythonpathclearupdate) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdold_pathZ old_modulesZ project_pathrrrrKs@           (     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. PYTHONPATHr N) objectosenvirongetpathsepjoinrrpop)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrras    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):rN) startswithr).0kvrrr sz%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rTZir_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)announcerWARNryr?rk_argvdry_runroperator attrgetterrarK run_tests)rZinstalled_distscmdrmrrrruns    ztest.runcCstjs~t|jddr~|jdd}|tvr~g}|tjvrD| ||d7}tjD]}| |rR| |qRt t tjj |tjdd|j||j||jdd}|jsd|j}||tjt|dS)NrNFr!r)Z testLoaderZ testRunnerexitzTest failed: %s)rrWr@r?r:splitr rHr]r$rqrCr __delitem__unittestmainr~_resolve_as_epr<r=resultZ wasSuccessfulr|rERRORr)rr*Z del_modulesnamer6rArrrrs*         ztest.run_testscCs dg|jS)Nr)rErrrrr~ sz test._argvcCs$|dur dStd|}|S)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseresolve)valparsedrrrrsztest._resolve_as_epN)r'r/r0__doc__ description user_optionsr>rBr1rErDrM contextlibcontextmanagerrK staticmethodraryrrpropertyr~rrrrrr6Js, -   r6)$rgrrHrrwrdistutils.errorsrr distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrr pkg_resourcesr r r r r rrrr setuptoolsrrOrtype __metaclass__rr1r6rrrrs"   ,  )