;ò E¬µ@c@s=dZdkZdkZdkZdkZdkZdkZdkZdkZdk l Z e Z dfd„ƒYZ d„Zd„Zd„Zed„Zed „Zd „Zd „Zed „Zed „Zdeifd„ƒYZdeifd„ƒYZd„Zedjo eeiƒZei eƒndS(sõ SchoolTool test runner. Syntax: test.py [options] [pathname-regexp [test-regexp]] There are two kinds of tests: - unit tests (or programmer tests) test the internal workings of various components of the system - functional tests (acceptance tests, customer tests) test only externaly visible system behaviour You can choose to run unit tests (this is the default mode), functional tests (by giving a -f option to test.py) or both (by giving both -u and -f options). Test cases are located in the directory tree starting at the location of this script, in subdirectories named 'tests' for unit tests and 'ftests' for functional tests, in Python modules named 'test*.py'. They are then filtered according to pathname and test regexes. Alternatively, packages may just have 'tests.py' and 'ftests.py' instead of subpackages 'tests' and 'ftests' respectively. A leading "!" in a regexp is stripped and negates the regexp. Pathname regexp is applied to the whole path (package/package/module.py). Test regexp is applied to a full test id (package.package.module.class.test_method). Options: -h print this help message -v verbose (print dots for each test run) -vv very verbose (print test names) -q quiet (do not print anything on success) -w enable warnings about omitted test cases -p show progress bar (can be combined with -v or -vv) -u select unit tests (default) -f select functional tests --level n select only tests at level n or lower --all-levels select all tests --list-files list all selected test files --list-tests list all selected test cases --list-hooks list all loaded test hooks --coverage create code coverage reports N(sSetsOptionscBs€tZdZdZeZeZeZdZ dZ dZ eZ eZ eZeZdZdZeZeZeZdZeZdZRS(s+Configurable properties of the test runner.siiscoverageiP(s__name__s __module__s__doc__sbasedirsTruesfollow_symlinkssFalses unit_testssfunctional_testsslevelspathname_regexs test_regexs list_filess list_testss list_hookss run_testss verbositysquiets warn_omittedsprogressscoveragescoverdirsimmediate_errorss screen_width(((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysOptionsOs( csy| o d„Snc|djo d„SnK|idƒo!ti|dƒ‰‡d†Snti|ƒ‰‡d†SdS(sîReturns a function that takes one argument and returns True or False. Regex is a regular expression. Empty regex matches everything. There is one expression: if the regex starts with "!", the meaning of it is reversed. cCstS(N(sTrue(sx((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys|ss!cCstS(N(sFalse(sx((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys~sicsˆi|ƒtjS(N(srxssearchsxsNone(sx(srx(s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysscsˆi|ƒtj S(N(srxssearchsxsNone(sx(srx(s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys„sN(sregexs startswithsrescompilesrx(sregexsrx((srxs5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pyscompile_matcherts   cCs®yti|ƒ}Wntij o dSnX||||ƒddf}x[|D]S}||jo@ti i ||ƒ}ti i |ƒot |||ƒq¦qSqSWdS(sƒLike os.path.walk, but follows symlinks on POSIX systems. If the symlinks create a loop, this function will never finish. Ns.s..( sosslistdirstopsnamesserrorsfuncsargs exceptionssnamespathsjoinsisdirswalk_with_symlinks(stopsfuncsargsnamesnamess exceptions((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pyswalk_with_symlinks‡s   cs¾t|iƒ‰g‰g‰|ioˆidƒn|ioˆidƒnt |i ƒd‰‡‡‡‡d†}|i o t}n tii}||i |tƒˆiƒˆSdS(s(Returns a list of test module filenames.stestssftestsicstii|ƒˆjoix^ˆD]V}|d|jo?tii||dƒ}ˆ|ˆƒoˆi |ƒqvq q WdSnd|jot i d|IJdSnxi|D]a}|idƒo |idƒo;tii||ƒ}ˆ|ˆƒoˆi |ƒqq¯q¯WdS(Ns.pys __init__.pys%s is not a packagestest(sosspathsbasenamesdirs test_namessnamesfilessjoinsmatchersbaselensresultssappendssyssstderrsfiles startswithsendswith(signoredsdirsfilessnamesfilespath(s test_namessmatchersresultssbaselen(s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysvisit£s"  N(scompile_matcherscfgspathname_regexsmatchersresultss test_namess unit_testssappendsfunctional_testsslensbasedirsbaselensvisitsfollow_symlinksswalk_with_symlinksswalkersosspathswalksNonessort(scfgs test_namessvisitsresultssbaselensmatcherswalker((s test_namessresultssbaselensmatchers5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysget_test_files™s       cCsÃtii|ƒd}|t|iƒitiidƒ}|i dƒo|d}n|t j o|i t|ƒ}n t|ƒ}|idƒ}x!|dD]}t||ƒ}q¢W|SdS(sImports and returns a module.is.iN(sosspathssplitextsfilenameslenscfgsbasedirsreplacessepsmodnames startswithstracersNonesrunfuncs __import__smodssplits componentsscompsgetattr(sfilenamescfgstracersmodnames componentsscompsmod((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys import_module¼s%   cCsÖt|tiƒ otd|ƒ‚ng}xž|iD]“}|t j ot |ddƒ|joq7nt|ti ƒo.|i ƒ}||ƒo|i|ƒqÊq7t|||ƒ}|i|ƒq7W|SdS(sDReturns a flattened list of test cases that match the given matcher.snot a TestSuitesleveliN(s isinstancessuitesunittests TestSuites TypeErrorsresultss_testsstestslevelsNonesgetattrsTestCasesidstestnamesmatchersappendsfilter_testsuitesfilteredsextend(ssuitesmatcherslevelsresultsstestnamesfilteredstest((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysfilter_testsuiteÌs &  cCs‰g}xxt|ƒD]j}|idƒ oqnt||ƒ}t|tt i fƒot |t i ƒo|i|ƒqqW|SdS(sBReturns a list of all test case classes defined in a given module.sTestN(sresultssdirsmodulesnames startswithsgetattrsitems isinstancestypestypess ClassTypes issubclasssunittestsTestCasesappend(smodulesnamesresultssitem((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysget_all_test_casesÞs ,cCsŒt|tiƒ otd|ƒ‚ntƒ}xQ|iD]F}t|ti ƒo|i |i ƒq:t |ƒ}|i|ƒq:W|SdS(s8Returns a set of test case classes used in a test suite.snot a TestSuiteN(s isinstancessuitesunittests TestSuites TypeErrorsSetsresultss_testsstestsTestCasesadds __class__sget_test_classes_from_testsuitesclassessupdate(ssuitesclassessresultsstest((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysget_test_classes_from_testsuiteës   c CsJt|iƒ}g}x*|D]"}t||d|ƒ}|t j o|i |i ƒ} n |i ƒ} | t joqn|i oett|ƒƒ}t| ƒ} || } x:| D].} tiJtid|| ifIJtiJq³Wn|it j ot| ddƒ|ijoqnt| ||iƒ}|i|ƒqW|SdS(s?Returns a list of test cases from a given list of test modules.stracers!%s: WARNING: %s not in test suitesleveliN(scompile_matcherscfgs test_regexsmatchersresultss test_filessfiles import_modulestracersmodulesNonesrunfuncs test_suites warn_omittedsSetsget_all_test_casess all_classessget_test_classes_from_testsuitesclasses_in_suites differences test_classssyssstderrs__name__slevelsgetattrsfilter_testsuitesfilteredsextend( s test_filesscfgstracersresultssmodulesfiles all_classessfilteredsmatchers test_classs differences test_suitesclasses_in_suite((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysget_test_casesùs2      ,c Cs)g}tttii|ƒƒ}xYt|ƒD]K}tii |ƒdjo,|i tii tii|ƒdƒƒq.q.Wt|ƒ}|i ƒx‹|D]ƒ}tii |dƒ}tii|ƒoUt||d|ƒ}|tj o|i|iƒ}n |iƒ}|i|ƒqšqšW|SdS(s?Returns a list of test hooks from a given list of test modules.sftestsstestss checks.pystracerN(sresultssSetsmapsosspathsdirnames test_filessdirsslistsdirsbasenamesaddsjoinssortsfilenamesexistss import_modulescfgstracersmodulesNonesrunfuncs test_hooksshookssextend( s test_filesscfgstracersdirssresultssmodulesfilenamesdirshooks((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysget_test_hookss& 0    sCustomTestResultcBsŒtZdZeiZeiZeiZ ei Z ei Z d„Zd„Zd„Z d„Zd„Z d„Zd„Zd„Zd „ZRS( s´Customised TestResult. It can show a progress bar, and displays tracebacks for errors and failures as soon as they happen, in addition to listing them all at the end. cCsl|i|||ƒ||_||_||_|io0t |_ d|_ |i t dƒd|_ndS(Nisxxxx/xxxx (xxx.x%): i(sselfs_CustomTestResult__super_initsstreams descriptionss verbosityscountscfgshookssprogresssFalsesdotss _lastWidths screen_widthslens _maxWidth(sselfsstreams descriptionss verbosityscountscfgshooks((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys__init__:s      cCs7|iioø|id}|iid|ƒ|io,|iid|i|d|ifƒn|io|iidƒns|ii oe|i |ƒ}t |ƒ}||ijo|d|i|7}n|iid|ƒ||_n|iiƒn|i|ƒx|iD]}|i|ƒqWdS(Nis %4ds /%d (%5.1f%%)f100.0s: s s: %s(sselfscfgsprogressstestsRunsnsstreamswritescountsshowAlls verbositysgetShortDescriptionstestsnameslenswidths _lastWidthsflushs"_CustomTestResult__super_startTestshooksshooks startTest(sselfstestsnameshooksnswidth((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys startTestDs&   ,      cCs2x|iD]}|i|ƒq W|i|ƒdS(N(sselfshooksshooksstopTeststests!_CustomTestResult__super_stopTest(sselfstestshook((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysstopTest\s cCsš|i|ƒ}t|ƒ|ijom|idƒ}|tdƒ|ijo||id d}q’d||d ||d|if}n|SdS(Ns (s (...)is...s%s...%sii(sselfsgetDescriptionstestssslens _maxWidthsfindspos(sselfstestssspos((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysgetShortDescriptionas+cCsA|iio|ip|i o|iiƒn|iƒdS(N(sselfscfgsprogresssdotssshowAllsstreamswritelns$_CustomTestResult__super_printErrors(sself((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys printErrorsos"cCsditi|ŒƒSdS(Ns(sjoins tracebacksformat_exceptionserr(sselfserr((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys formatErrortscCs^|iiƒ|iiƒ|iid||fƒ|ii|i|ƒƒ|iiƒdS(Ns%s: %s(sselfsstreamswritelnskindstests formatErrorserr(sselfskindstestserr((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysprintTracebackws   cCsG|iio|id||ƒn|ii||i|ƒfƒdS(NsFAIL( sselfscfgsimmediate_errorssprintTracebackstestserrsfailuressappends formatError(sselfstestserr((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys addFailure~s cCsG|iio|id||ƒn|ii||i|ƒfƒdS(NsERROR( sselfscfgsimmediate_errorssprintTracebackstestserrserrorssappends formatError(sselfstestserr((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysaddErrorƒs (s__name__s __module__s__doc__sunittests_TextTestResults_CustomTestResult__supers__init__s_CustomTestResult__super_inits startTests"_CustomTestResult__super_startTestsstopTests!_CustomTestResult__super_stopTests printErrorss$_CustomTestResult__super_printErrorssgetShortDescriptions formatErrorsprintTracebacks addFailuresaddError(((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysCustomTestResult-s             sCustomTestRunnercBsGtZdZeiZeiZeiZ e d„Zd„Zd„Z RS(sSCustomised TestRunner. See CustomisedTextResult for a list of extensions. cCsC|id|iƒ||_|tj o ||_n g|_dS(Ns verbosity(sselfs_CustomTestRunner__super_initscfgs verbosityshookssNone(sselfscfgshooks((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys__init__“s    c Cs™|iƒ|_|iƒ}tiƒ}||ƒtiƒ}t ||ƒ}|i ƒ|i }|ii oU|ii|iƒ|iid||djodpd|fƒ|iiƒn|iƒ ož|iidƒtt|i|ifƒ\}}|o|iid|ƒn|o3|o|iidƒn|iid|ƒn|iid ƒn#|ii o|iid ƒn|Sd S( s&Run the given test case or test suite.sRan %d test%s in %.3fsissssFAILED (s failures=%ds, s errors=%ds)sOKN(stestscountTestCasessselfscounts _makeResultsresultstimes startTimesstopTimesfloats timeTakens printErrorsstestsRunsrunscfgsquietsstreamswritelns separator2s wasSuccessfulswritesmapslensfailuresserrorssfailedserrored( sselfstestsruns timeTakensfailedsstopTimesresults startTimeserrored((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysrun›s4      1!c Cs8t|i|i|id|id|id|iƒSdS(Nscfgscountshooks(sCustomTestResultsselfsstreams descriptionss verbosityscfgscountshooks(sself((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys _makeResult·s( s__name__s __module__s__doc__sunittestsTextTestRunners_CustomTestRunner__supers__init__s_CustomTestRunner__super_initsruns_CustomTestRunner__super_runsNones _makeResult(((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysCustomTestRunner‰s      cCs•tiddfjo1tid|dIJtidtiIJdSntƒ}tii tii |dƒdƒ|_ tii |i ƒ|_ y dk }Wntj onRXy7|iƒ|id ƒ}|djo ||_nWn|ij onXti|dd d d d dddgƒ\}} x#|D]\}}|djo tGHdSq;|djo|id7_t|_q;|djot|_t|_q;|djod|_t|_t|_q;|djo t|_ q;|djo t|_!q;|djo t|_"q;|djot|_#t|_$q;|djot|_%t|_$q;|djot|_&t|_$q;|djo t|_'q;|djoYyt(|ƒ|_)WqVt*j o3tid|d|fIJtidIJdSqVXq;|djo t+|_)q;tid |d|fIJtidIJdSq;W| o| d|_,nt-| ƒdjo| d|_.nt-| ƒdjo4tid!|d| dfIJtidIJdSn|i o|i! o t|_ n|i tidi?|i@ƒt}|i#oJt-|i ƒd}d(i giC}|D]}|||ƒq9~ƒGHn|i%o9d(i giC}|D]} || iGƒƒqz~ƒGHn|i&o9d(i giC}|D]}|tI|ƒƒq½~ƒGHn|i$o’tJ||ƒ}tLiMƒ} | iO|ƒ|t+j oD|iP|iQ| ƒiRƒ}|iSƒ} | iTd)td*|iUƒq~|iQ| ƒiRƒ}n|odSndSdS(+s Main program.iis%s: need Python 2.3 or laterisyour python is %sissrcNscolsshvpqufws list-filess list-testss list-hooksslevel=s all-levelsscoverages-hs-vs-ps-qs-us-fs-ws --list-filess --list-testss --list-hookss --coverages--levels%s: invalid level: %ssrun %s -h for helps --all-levelss%s: invalid option: %ss%s: too many arguments: %sstestscountstraces ignoremodss ignoredirsstracers s show_missingscoverdir(Vssyss version_infosstderrsargvsversionsOptionsscfgsosspathsjoinsdirnamesbasedirsabspathscursess ImportErrors setuptermstigetnumscolss screen_widthserrorsgetopts gnu_getoptsoptssargssksvs__doc__s verbositysFalsesquietsTruesprogresss unit_testssfunctional_testss warn_omitteds list_filess run_testss list_testss list_hooksscoveragesintslevels ValueErrorsNonespathname_regexslens test_regexstracerstraces ignoremodssprefixs exec_prefixs ignoredirssTracesget_test_filess test_filessget_test_casess test_casessget_test_hookss test_hookssloggings basicConfigsrootssetLevelsCRITICALssuccesssbaselensappends_[1]sfnstestsidshooksstrsCustomTestRunnersrunnersunittests TestSuitessuitesaddTestssrunfuncsruns wasSuccessfulsresultss write_resultsscoverdir(sargvscursesscfgscolss test_hooksshooksrunners_[1]sfnsteststracesargssresultsssuitesloggings test_filess ignoremodsssuccesss test_casessks ignoredirssbaselensvstracersopts((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pysmain½sÞ (   !                                          7 9 9     s__main__(!s__doc__sresosssysstimestypessgetoptsunittests tracebackssetssSetstypes __metaclass__sOptionsscompile_matcherswalk_with_symlinkssget_test_filessNones import_modulesfilter_testsuitesget_all_test_casessget_test_classes_from_testsuitesget_test_casessget_test_hookss_TextTestResultsCustomTestResultsTextTestRunnersCustomTestRunnersmains__name__sargvsexitcodesexit(sget_test_filessget_test_classes_from_testsuites __metaclass__sget_test_hookssunittestscompile_matchersget_test_casessresgetoptsmainstimessyssCustomTestResultswalk_with_symlinkssget_all_test_casessOptionsstypessSetsCustomTestRunners tracebacksfilter_testsuites import_modulesossexitcode((s5/mnt/gmirror/ports/www/zope-silva/work/Sprout/test.pys?<s4         %   #     \4 ‘