U Qab%@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_visitedselfr;/usr/lib/python3.8/site-packages/setuptools/command/test.pyrs zScanningLoader.__init__NcCs||jkrdS|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)rmodulepatternZtestsfileZ submodulerrrr%s$      z"ScanningLoader.loadTestsFromModule)N)r' __module__ __qualname__rr%rrrrrsrc@seZdZddZdddZdS)NonDataPropertycCs ||_dSrfget)rr1rrrrAszNonDataProperty.__init__NcCs|dkr |S||Srr0)robjZobjtyperrr__get__DszNonDataProperty.__get__)N)r'r-r.rr3rrrrr/@sr/c@seZdZdZdZdddgZddZdd Zed d Z d d Z ddZ 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||jdkrD|jdkr8|jj|_n |jd|_|jdkr^t|jdd|_|jdkrnd|_|jdkrt|jdd|_dS)Nz1You may specify a module or a suite, but not bothz .test_suiter:z&setuptools.command.test:ScanningLoaderr;)r8r9r 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)r8sys version_infoverboserrrrrBss ztest._test_argsc Cs| |W5QRXdS)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 csPtjot|jdd}|rv|jddd|d|d}t|j}|jd|d|d|jddd|dn"|d|jdd d|d|d}t j dd}t j }zbt|j}t j d|ttd d td |j|jf||g dVW5QRXW5|t j dd<t j t j |tXdS) Nuse_2to3Fbuild_pyr)ZinplaceZegg_info)egg_baseZ build_extrcSs|Sr)Zactivate)distrrrz*test.project_on_sys_path..z%s==%s)rPY3r>r=Zreinitialize_commandZ run_commandZget_finalized_commandr Z build_librFpathmodulescopyclearupdater rrNinsertrrZegg_nameZ egg_versionpaths_on_pythonpath) rZ include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathrrrrIs8             ztest.project_on_sys_pathc cst}tjd|}tjdd}zBtjt|}td||g}tj|}|r\|tjd<dVW5||kr~tjddn |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) objectosenvirongetpoppathsepjoinrr)pathsZnothingZorig_pythonpathZcurrent_pythonpathprefixZto_joinnew_pathrrrrYs    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 s z%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rOZir_dZtr_dZer_drrr install_distss   ztest.install_distsc Cs|dtj||j}d|j}|jr>|d|dS|d|tt d|}| |"| | W5QRXW5QRXdS)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)announcerZWARNrmr=r`_argvZdry_runroperator attrgetterrYrI run_tests)rZinstalled_distscmdrarrrruns    ztest.runcCstjr~t|jddr~|jdd}|tkr~g}|tjkrD| ||d7}tjD]}| |rR| |qRt t tjj |tjdd|j||j||jdd}|jsd|j}||tjt|dS)NrLFr!r)Z testLoaderZ testRunnerexitzTest failed: %s)rrRr>r=r8splitr rFrTr$rerAr __delitem__unittestmainrq_resolve_as_epr:r;resultZ wasSuccessfulrprZERRORr)rr*Z del_modulesnamer4r?rrrrts.         ztest.run_testscCs dg|jS)Nrz)rCrrrrrq sz test._argvcCs$|dkr dStd|}|S)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseZresolve)valZparsedrrrr|sztest._resolve_as_epN)r'r-r.__doc__ descriptionZ user_optionsr<r@r/rCrBrK contextlibcontextmanagerrI staticmethodrYrmrvrtpropertyrqr|rrrrr4Js2 -   r4)$r[rrrFrrkrzZdistutils.errorsrrZ distutilsrrZsetuptools.externrZsetuptools.extern.six.movesrrZ pkg_resourcesr r r r r rrrrZ setuptoolsrrMrtypeZ __metaclass__rr/r4rrrrs"   ,  )