ó J9•Qc@s…dZddlZddlZddlZddlZddlmZddlmZm Z ej e ƒZ defd„ƒYZ dS(s°If you have Ned Batchelder's coverage_ module installed, you may activate a coverage report with the ``--with-coverage`` switch or NOSE_WITH_COVERAGE environment variable. The coverage report will cover any python source module imported after the start of the test run, excluding modules that match testMatch. If you want to include those modules too, use the ``--cover-tests`` switch, or set the NOSE_COVER_TESTS environment variable to a true value. To restrict the coverage report to modules from a particular package or packages, use the ``--cover-package`` switch or the NOSE_COVER_PACKAGE environment variable. .. _coverage: http://www.nedbatchelder.com/code/modules/coverage.html iÿÿÿÿN(tPlugin(tsrcttolisttCoveragecBsqeZdZeZdZdZeZdZ dZ iZ d„Z d„Z d„Zd„Zd„Zdd„ZRS( sL Activate a coverage report using Ned Batchelder's coverage module. iÈc Cstt|ƒj||ƒ|jdddd|jdƒdddd d d ƒ|jd dd d|jdƒddd dƒ|jddd ddd|jdƒd dƒ|jdddddd|jdƒd dƒ|jddd ddd|jdƒd dƒ|jddd d|jdƒdd d d!ƒ|jd"ddd|jd#d$ƒdd%dd&d d'ƒ|jd(dd d|jd)ƒdd*d d+ƒ|jd,dd d|jd-ƒdd.d d/ƒ|jd0ddd|jd1d2ƒdd3dd4d d5ƒd6S(7s. Add options to command line. s--cover-packagetactiontappendtdefaulttNOSE_COVER_PACKAGEtmetavartPACKAGEtdesttcover_packagesthelpsBRestrict coverage output to selected packages [NOSE_COVER_PACKAGE]s --cover-eraset store_truetNOSE_COVER_ERASEt cover_erases9Erase previously collected coverage statistics before runs --cover-testst cover_teststNOSE_COVER_TESTSs:Include test modules in coverage report [NOSE_COVER_TESTS]s--cover-min-percentagetstoretcover_min_percentagetNOSE_COVER_MIN_PERCENTAGEsKMinimum percentage of coverage for teststo pass [NOSE_COVER_MIN_PERCENTAGE]s--cover-inclusivetcover_inclusivetNOSE_COVER_INCLUSIVEs»Include all python files under working directory in coverage report. Useful for discovering holes in test coverage if not all files are imported by the test suite. [NOSE_COVER_INCLUSIVE]s --cover-htmltNOSE_COVER_HTMLt cover_htmls!Produce HTML coverage informations--cover-html-dirtNOSE_COVER_HTML_DIRtcovertcover_html_dirtDIRs(Produce HTML coverage information in dirs--cover-branchestNOSE_COVER_BRANCHEStcover_branchess@Include branch coverage in coverage report [NOSE_COVER_BRANCHES]s --cover-xmltNOSE_COVER_XMLt cover_xmls Produce XML coverage informations--cover-xml-filetNOSE_COVER_XML_FILEs coverage.xmltcover_xml_filetFILEs(Produce XML coverage information in fileN(tsuperRtoptionst add_optiontget(tselftparsertenv((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyR%#sXcCsZy|jjdƒWntk r'nXtt|ƒj||ƒ|jrNdS|jr³y.ddl}t |dƒs„t dƒ‚nWq³t k r¯t j dƒt |_dSXn||_|j|_|j|_g|_|jrSt|jttfƒr |j}n |jg}x:g|D]}t|ƒ^q D]}|jj|ƒq6Wn|j|_|jr~t jd|jƒnd|_|jr²|j |_t j!d|jƒn|j"|_#d|_$|j%rît&|j%j'd ƒƒ|_(n|j)r|j*|_$t j!d |j$ƒn|jrVt+|jd<|jd t d |j#d dƒ|_,ndS(s# Configure plugin. tactiveNiÿÿÿÿtcoverages Unable to import coverage modules8Coverage not available: unable to import coverage modules.Coverage report will include only packages: %ss#Will put HTML coverage report in %st%s"Will put XML coverage report in %st auto_datatbrancht data_suffix(-tstatustpoptKeyErrorR$Rt configuretworkertenabledR,thasattrt ImportErrortlogterrortFalsetconfRt coverEraseRt coverTestst coverPackagesR t isinstancetlistttupleRtextendRtcoverInclusivetinfotNonet coverHtmlDirRRtdebugRt coverBranchest coverXmlFileRtinttrstriptcoverMinPercentageR R"tTruet coverInstance(R(R%R<R,R txtpkgs((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyR4]sZ              &              cCstjdƒtjjƒ|_|jrStjdƒ|jjƒ|jj ƒn|jj dƒ|jj ƒ|jj ƒdS(s7 Begin recording coverage information. sCoverage begins1Clearing previously collected coverage statisticss)#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]N( R9RHtsystmodulestkeyst skipModulesR=ROtcombineterasetexcludetloadtstart(R(((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pytbegin‘s     c CsÎtjdƒ|jjƒ|jjƒ|jjƒgtjjƒD]$\}}|j ||ƒrD|^qD}tjd|ƒ|jj |d|ƒ|j rÃtjdƒ|jj ||j ƒn|j ròtjdƒ|jj||j ƒn|jrÊtjƒ}|jj |d|ƒd}d}tj||jƒƒ}|d krhtj||jƒƒ}n|rºt|jƒdƒ} | |jkrÇtjd |jƒtjd ƒqÇqÊtjd ƒnd S( s. Output code coverage report. sCoverage reports&Coverage report will cover modules: %stfilesGenerating HTML coverage reportsGenerating XML coverage reports@-------\s\w+\s+\d+\s+\d+(?:\s+\d+\s+\d+)?\s+(\d+)%\s+\d*\s{0,1}$sM-------\s[\w./]+\s+\d+\s+\d+(?:\s+\d+\s+\d+)?\s+(\d+)%(?:\s+[-\d, ]+)\s{0,1}$is3TOTAL Coverage did not reach minimum required: %d%%isGNo total percentage was found in coverage output, something went wrong.N(R9RHROtstopRVtsaveRRRStitemstwantModuleCoveragetreportRGt html_reportRJt xml_reportRMtStringIOtretsearchtgetvalueRFRKtgroupsR:texit( R(tstreamtnametmoduleRStftmultiPackageRetsinglePackageRetmt percentage((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyRaŸs<             cCs-t|dƒs#tjd|ƒtSt|jƒ}| sI|jdƒ r]tjd|ƒtS|jrÏxf|jD]X}tj dtj |ƒ|ƒrp|j s´|j j j|ƒ rptjd|ƒtSqpWn||jkròtjd|ƒtS|j j j|ƒr%|j r%tjd|ƒtS|j S( Nt__file__sno coverage of %s: no __file__s.pys$no coverage of %s: not a python files^%s\bscoverage for %ss0no coverage for %s: loaded before coverage startsno coverage for %s: is a test(R7R9RHR;RRrtendswithR?RetfindalltescapeR>R<t testMatchRfRNRU(R(RkRlt module_filetpackage((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyR`Ìs,    cCs_|jr[|jdƒr[|rQ|jrQx+|jD]}|j|ƒr1tSq1WqXtSq[ndS(sdIf inclusive coverage enabled, return true for all source files in wanted packages. s.pyN(RDRsR?t startswithRNRF(R(R\Rxtwant((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pytwantFileçs   N(t__name__t __module__t__doc__R;R>RFR?ROR=RMtscoreR1R%R4R[RaR`R{(((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyRs : 4  - (R~tloggingReRRRdtnose.plugins.baseRt nose.utilRRt getLoggerR|R9R(((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyt s