Yp"@s4ddlZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl Z ddl mZmZddlmZmZmZmZmZmZmZmZddlmZddlmZGd d d e ZGd d d eZGd ddeZ dS)N)DistutilsErrorDistutilsOptionError)log) TestLoader)mapfilter)resource_listdirresource_existsnormalize_path working_set_namespace_packagesadd_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&=/tmp/pip-build-3puug3g5/setuptools/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,r.r&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=s1Test suite to run (e.g. 'some_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<)r9r: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)verboser9)r r&r&r'rCgs  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)sixPY3r?r>reinitialize_command run_commandget_finalized_commandr build_libsyspathmodulescopyrLinsertr r,r regg_nameZ egg_versionpaths_on_pythonpathclearupdate) r Z include_distsZ with_2to3Zbpy_cmdZ build_pathZei_cmdZold_pathZ old_modulesZ project_pathr&r&r'rFts8      ztest.project_on_sys_pathc cst}tjjd|}tjjdd}zUtjj|}td||g}tjj|}|r|tjdrf_argvdry_runannounceroperator attrgetterr]rF run_tests)r installed_distscmdrhr&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) NrIFrrexitZ testLoaderZ testRunnerzTest failed: %s)ryrz)rQrRr?r>r9splitr rWrYr startswithrBr __delitem__ version_inforrp_resolve_as_epr;r<resultZ wasSuccessfulrrrERRORr)r r!Z del_modulesnameZ exit_kwargr/r@r&r&r'rus*   !  ztest.run_testscCsdg|jS)Nunittest)rD)r r&r&r'rpsz 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)r0r1r2)r3r4r5)r6r7r8)rr(r)__doc__ description user_optionsr=rAr*rDrCrH contextlibcontextmanagerrF staticmethodr]rmrxrupropertyrprr&r&r&r'r/>s(      -  r/)!rbrsrWrrkdistutils.errorsrr distutilsrrrrQZ six.movesrr pkg_resourcesrr r r r r rr setuptoolsrZsetuptools.py31compatrrrar*r/r&r&r&r's      :