ReT#@s>ddlZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl m Z ddlmZmZddlmZmZmZmZmZmZmZmZmZddlmZdd lmZGd d d e ZGd d d e Z!GdddeZ"dS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)six)mapfilter) resource_listdirresource_existsnormalize_path working_set_namespace_packagesevaluate_markeradd_activation_listenerrequire EntryPoint)Command) unittest_mainc@seZdZdddZdS)ScanningLoaderNcCsg}|jtj||t|drA|j|jt|drxt|jdD]}|jdr|dkr|jd|dd }n-t|j|d rc|jd|}nqc|j|j |qcWt |d kr|j |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. additional_tests__path__z.pyz __init__.py.Nz /__init__.pyr) appendrloadTestsFromModulehasattrrr __name__endswithr ZloadTestsFromNamelenZ suiteClass)selfmodulepatterntestsfile submoduler(/builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/command/test.pyrs z"ScanningLoader.loadTestsFromModule)r __module__ __qualname__rr(r(r(r)rs rc@s+eZdZddZdddZdS)NonDataPropertycCs ||_dS)N)fget)r"r-r(r(r)__init__5szNonDataProperty.__init__NcCs|dkr|S|j|S)N)r-)r"objZobjtyper(r(r)__get__8s zNonDataProperty.__get__)rr*r+r.r0r(r(r(r)r,4s  r,c@seZdZdZdZd%d&d'gZd d ZddZeddZ ddZ ddZ e j gddZee j ddZeddZddZddZed d!Zed"d#Zd$S)(testz.Command to run unit tests after in-place buildz#run unit tests after in-place build test-module=m$Run 'test_suite' in specified module test-suite=s9Run single test, case or suite (e.g. 'module.test_suite') test-runner=rTest runner to usecCs(d|_d|_d|_d|_dS)N) test_suite test_module test_loader test_runner)r"r(r(r)initialize_optionsJs   ztest.initialize_optionscCs|jr$|jr$d}t||jdkrd|jdkrT|jj|_n|jd|_|jdkrt|jdd|_|jdkrd|_|jdkrt|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>)r"msgr(r(r)finalize_optionsPs  ztest.finalize_optionscCst|jS)N)list _test_args)r"r(r(r) test_argscsztest.test_argsccs#|jrdV|jr|jVdS)Nz --verbose)verboser;)r"r(r(r)rEgs  ztest._test_argsc Cs|j |WdQRXdS)zI Backward compatibility for project_on_sys_path context. N)project_on_sys_path)r"funcr(r(r)with_project_on_sys_pathms ztest.with_project_on_sys_pathc cstjot|jdd}|r|jddd|jd|jd}t|j}|jdd||jd|jddd|jdn-|jd|jddd |jd|jd}t j dd}t j j }zyt|j }t j jd|tjtd d td |j|jf|j|g dVWdQRXWd|t j ddsz*test.project_on_sys_path..z%s==%s)rPY3rAr@reinitialize_command run_commandget_finalized_commandr build_libsyspathmodulescopyrNinsertr r.rregg_nameZ egg_versionpaths_on_pythonpathclearupdate) r"Z include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdold_pathZ old_modulesZ project_pathr(r(r)rHts8      ztest.project_on_sys_pathc cst}tjjd|}tjjdd}zUtjj|}td||g}tjj|}|r|tjds z%test.install_dists..)Zfetch_build_eggsZinstall_requiresZ tests_requireZextras_requireitems itertoolschain)rQZir_dZtr_dZer_dr(r(r) install_distss ztest.install_distscCs|j|j}dj|j}|jrB|jd|dS|jd|ttjd|}|j |#|j |j WdQRXWdQRXdS)N zskipping "%s" (dry run)z running "%s"location) rvr@rh_argvdry_runannounceroperator attrgetterr^rH run_tests)r"Zinstalled_distscmdrjr(r(r)runs  ztest.runc CsQtjrt|jddr|jjdd}|tkrg}|tjkrb|j ||d7}x-tjD]"}|j |rv|j |qvWt t tjj |tjd krin ddi}tdd|jd|j|jd |j|j|}|jjsMd |j}|j|tjt|dS) NrKFrrexitZ testLoaderZ testRunnerzTest failed: %s)rr)rrSrAr@r;splitr rXrZrrnrDr __delitem__ version_inforry_resolve_as_epr=r>resultZ wasSuccessfulr{rERRORr)r"r#Z del_modulesnameZ exit_kwargr1rBr(r(r)r~s*   !  ztest.run_testscCsdg|jS)Nunittest)rF)r"r(r(r)rysz test._argvcCs0|dkrdStjd|}|jS)zu Load the indicated attribute value, called, as a as if it were specified as an entry point. Nzx=)rparseresolve)valparsedr(r(r)rs ztest._resolve_as_epN)r2r3r4)r5r6r7)r8r9r:)rr*r+__doc__ description user_optionsr?rCr,rFrErJ contextlibcontextmanagerrH staticmethodr^rvrr~propertyryrr(r(r(r)r1>s(      -  r1)#rdr|rXrrtdistutils.errorsrr distutilsrrrZsetuptools.externrZsetuptools.extern.six.movesrr pkg_resourcesr r r r r rrrr setuptoolsrZsetuptools.py31compatrrrcr,r1r(r(r(r)s     @