B t `[<@sdddgZddlZddlZddlZddlZddlmZmZddlm Z ddl m Z ddl mZddlmZyeWneZYnXd d Zd d Ze jdd dZe jddZddZdddZdddZdS)runmaincreate_test_suitesN)dirnameabspath)Options)ExtensionPoint)pluginscCst|trt|S|S)N) isinstance basestringstr)xrdtjkrx2tdtjdD]}|dkr|j| qW|dk r6|j dkrt t |tj |_ ttj}tj|d}|dks |dd}||}|dkr,td|||}t|xd|dgD]T}yt||Wn>tk rtd} td |td t| YnXqLWt|d } | dkrtd |d | |d <x$|diD]} t| |||qWdS)NrZPYUTILIB_AUTOTEST_CATEGORIES,ZPYUTILIB_UNITTEST_CATEGORIESzAUnknown file type. Cannot load test configuration from file '%s'rzERROR executing '%s'z Exception: %srzUnexpected test driver '%s' test_driverr) r categorieslenrosenvironresplitaddstripcurrdirrrseprr Z ITestParserpathsplitextservicerZload_test_configr getexec Exceptionsysexc_infoprintr ZTestDriverFactorycreate_test_suite) filenameconfig_globalsoptionscatepZftyper1itemerrrrrrrrXsT              cs^t|jdkrHd}x,|jD]"}||d|dgkrd}PqW|sHdS||kr\td|dd}tt|tjfd t|i||<|||j d<t ||d |d t ||d |d|dgg}d |d|krxz|d|d D]}| |d|d|fqWnHxF|d|dD]2} x*|d|dD]} | | | ifq8Wq"Wx|D]\} } }|j dkr| d| } n|j | | f} fdd|d _ t} |d|d| } | dk rd| kr| d}n| }x.|d|iD]\}}t|| |<qW| dk rDx"| D]\}}t|| |<q*W|d|d| }|dk rvd|krv|d}n| }|}x<|d|iD]$\}}t|| |<|dkr|}qW|dk rx"|D]\}}t|| |<qWx(|D] }|dkrt||| |<qWt|| _t|| _t|| _t|j| _||j| || dq`WdS)NrFrr%Tz^Cannot create suite '%s' since there is another symbol with that name in the global namespace!cSs|jd}|j||dS)N)_options _test_driver setUpClass)clsr<rrr setUpClassFns z'create_test_suite..setUpClassFnrCrBr$suite_categoriestestssolverproblemrr_cs>|j||f}j||j|||}j|||S)N)rAr$ZsetUpZrun_testZtearDown)Ztestcasenamerr<Zans)fnrrrLs zcreate_test_suite..fnrK)rIrH)rKrLrr<)r&r%r2rrr unittestTestCase classmethodrAsetattrappendZtestname_formatr$ritemsrrHrIrr-Z add_fn_test)rr:r;r<flagr=rErGr?rHrIZ test_namerAZproblem_optionsZ_problemattrvalueZsolver_optionsZ_solver_namerr)rLrr8s                  r8cCsx|D] }||=qWdS)Nr)r;rrrrrcleanups rWcCs|t_t}|d|jddddddd|jdd dd dd d|jd d ddddd|jddddddd|jddddddd|jddddddd|jddddddd|jd d!d"d#gd$d|jd%dd&dd'd|jd(d)d*dd+d|jd,dd-dd.d|tj\}}|jrF|t d/|d0|d0|d0fdS|dkrVt }t }|j |_ |j |_ |j|_|j|_g}x>|d1dD].}tj|rt|||d2n ||qWg}t} x`|D]T} t|| tkrt|| tjr|| x|| jD]} | | qWqW|jr |dk r ||jd} t| tk rvt d3t|jt ||Sg} x(t!| D]}|"d4r| |qWt d5t#| d0krt d6|jx.t$| D]}t d7|qWnt d8|jt d5t ||S|j%s|j&r&|dk r&|j%rt d5t#|d0kr|t d9tj'|d0x8t$|D]} t d7| qdWnt d:tj'|d0t d5|j&rt(| }t d5t#|d0krt d;tj'|d0x8t$|D]} t d7| qWnt dt ||dS)?Nz-hz--help store_truehelpFzPrint command options)actiondestdefaultrYz-dz--debugdebugzSet debugging flagz-vz --verboseverbosezVerbose outputz-qz--quietquietzMinimal outputz-fz --failfastfailfastzStop on first failurez-cz--catchcatchz#Catch control-C and display resultsz-bz--bufferbufferz*Buffer stdout and stderr durring test runsz--catz --categoryrQr%zDDefine a list of categories that filter the execution of test suitesz --help-suites help_suitesz*Print the test suites that can be executedz --help-testsstore help_testsz+Print the tests in the specified test suitez--help-categorieshelp_categoriesz5Print the test suite categories that can be specifieda Examples: %s - run all test suites %s MyTestCase.testSomething - run MyTestCase.testSomething %s MyTestCase - run all 'test*' test methods in MyTestCase rr#)r9r;r<zTest suite '%s' not found!testr"z!Tests defined in test suite '%s':z z$No tests defined in test suite '%s':zTest suites defined in '%s':zNo test suites defined in '%s'!z&Test suite categories defined in '%s':z)No test suite categories defined in '%s':__name__)module)-r5argvoptparse OptionParser remove_option add_option parse_argsrY print_helpr7globalsrr]r^r_r%r'r/existsrrQrrr issubclassrMrNrFr+rer2r rWdir startswithr&sortedrcrfbasenamerr`rarbr)rjr;parserrAargsr<Z_argvargrr%rcrrGr?rrrrrs>              cCsttj|ddS)N)r;)rr5rj)r;rrrrs)NNNN)N)N)__all__r5rkr)r'os.pathrrZ pyutilib.ththrMZ pyutilib.miscrZpyutilib.component.corerZpyutilib.autotestr unicoder r rr Znottestrr8rWrrrrrr s,      - =d W