o _a@sddlZddlZddlZddlZddlZddlZddlmZmZddl m Z ddlm Z ddl m Z mZmZmZmZmZmZmZddlmZddlmZGdd d e ZGd d d ZGd d d eZdS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)resource_listdirresource_existsnormalize_path working_setevaluate_markeradd_activation_listenerrequire EntryPoint)Command)unique_everseenc@eZdZddZdddZdS)ScanningLoadercCst|t|_dSN)r__init__set_visitedselfr9/usr/lib/python3/dist-packages/setuptools/command/test.pyrs  zScanningLoader.__init__NcCs||jvrdS|j|g}|t||t|dr$||t|dr`t|jdD]0}| drF|dkrF|jd|dd}nt |j|d rV|jd|}nq/|| |q/t |d krk| |S|d S) 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__.pyr)raddappendrloadTestsFromModulehasattrrr__name__endswithrloadTestsFromNamelen suiteClass)rmodulepatterntestsfile submodulerrrr"s$      z"ScanningLoader.loadTestsFromModuler)r$ __module__ __qualname__rr"rrrrrsrc@r)NonDataPropertycCs ||_dSrfget)rr2rrrrBs zNonDataProperty.__init__NcCs|dur|S||Srr1)robjobjtyperrr__get__Es zNonDataProperty.__get__r)r$r.r/rr5rrrrr0Asr0c@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_optionsZs ztest.initialize_optionscCs|jr |jr d}t||jdur"|jdur|jj|_n|jd|_|jdur/t|jdd|_|jdur7d|_|jdurFt|jdd|_dSdS)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_argss ztest.test_argsccs:|js tjdkr dV|jrdV|jr|jVdSdS)N)discoverz --verbose)r:sys version_infoverboserrrrrDws ztest._test_argscCs4| |WddS1swYdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)rfuncrrrwith_project_on_sys_paths "ztest.with_project_on_sys_pathc csL|d|jddd|d|d}tjdd}tj}zkt|j}tj d|t t ddt d|j|jf||g dVWdn!1sXwYW|tjdd<tjtj|t dSW|tjdd<tjtj|t dS|tjdd<tjtj|t w) Negg_info build_extr)inplacercSs|Sr)activate)distrrrsz*test.project_on_sys_path..z%s==%s) run_commandreinitialize_commandget_finalized_commandrJpathmodulescopyregg_baseinsertr rr r egg_name egg_versionpaths_on_pythonpathclearupdate)r include_distsei_cmdold_path old_modules project_pathrrrrMs:               ztest.project_on_sys_pathc cst}tjd|}tjdd}z4tjt|}td||g}tj|}|r/|tjd<dVW||ur@tjdddS|tjd<dS||urStjddw|tjd<w)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. PYTHONPATHrN) objectosenvirongetpathsepjoinrfilterpop)pathsnothingorig_pythonpathcurrent_pythonpathprefixto_joinnew_pathrrrr`s"   ztest.paths_on_pythonpathcCsD||j}||jp g}|dd|jD}t|||S)z Install the requirements indicated by self.distribution and return an iterable of the dists that were built. css2|]\}}|drt|ddr|VqdS):rN) startswithr ).0kvrrr s z%test.install_dists..)fetch_build_eggsinstall_requires tests_requireextras_requireitems itertoolschain)rTir_dtr_der_drrr install_distss  ztest.install_distsc Cs|dtj||j}d|j}|jr|d|dS|d|tt d|}| |)| | Wdn1sGwYWddSWddS1s_wYdS)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)announcerWARNrr?rn_argvdry_runmapoperator attrgetterr`rM run_tests)rinstalled_distscmdrqrrrruns$     "ztest.runcCsVtjdd|j||j||jdd}|js)d|j}||t j t |dS)NF) testLoader testRunnerexitzTest failed: %s) unittestmainr_resolve_as_epr<r=result wasSuccessfulrrERRORr)rr6rArrrrs    ztest.run_testscCs dg|jS)Nr)rErrrrrrFz test._argvcCs$|durdStd|}|S)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)r parseresolve)valparsedrrrrs ztest._resolve_as_epN)r$r.r/__doc__ description user_optionsr>rBr0rErDrO contextlibcontextmanagerrM staticmethodr`rrrpropertyrrrrrrr6Ks.     r6)rjrrJrrrdistutils.errorsrr distutilsrr pkg_resourcesrrrr r r r r setuptoolsr setuptools.extern.more_itertoolsrrr0r6rrrrs  ( (