Current File : //usr/lib/python2.7/site-packages/nose/plugins/cover.pyo
�
��Uc@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(tsrcttolisttCoveragecBszeZdZeZd	Zd	ZeZd	Z	dZ
iZd�Zd�Z
d�Zd�Zd�Zd�Zd	d�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_ERASEtcover_erases9Erase previously collected coverage statistics before runs
--cover-teststcover_teststNOSE_COVER_TESTSs:Include test modules in coverage report [NOSE_COVER_TESTS]s--cover-min-percentagetstoretcover_min_percentagetNOSE_COVER_MIN_PERCENTAGEsLMinimum percentage of coverage for tests to 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/usr/lib/python2.7/site-packages/nose/plugins/cover.pyR%#sXc	Csy|jjd�Wntk
r'nXtt|�j||�|jr�y.ddl}t|d�swt	d��nWq�t	k
r�t
jd�t|_dSXn||_
|j|_|j|_g|_|jrFt|jttf�r�|j}n|jg}x:g|D]}t|�^qD]}|jj|�q)Wn|j|_|jrqt
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|jr�t*|jd<|jdtd|j"d
|j+d|j�|_,t|j,_-|j+|j,_.|j,j/d�t
j d�t0j1j2�|_3|jr�t
j d�|j,j4�|j,j5�n|j,j.s�|j,j6�|j,j7�q�ndS(s#
        Configure plugin.
        tactivei����Ntcoverages 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_datatbranchtdata_suffixtsources)#pragma[: ]+[nN][oO] [cC][oO][vV][eE][rR]sCoverage begins1Clearing previously collected coverage statistics(8tstatustpoptKeyErrorR$Rt	configuretenabledR,thasattrtImportErrortlogterrortFalsetconfRt
coverEraseRt
coverTestst
coverPackagesRt
isinstancetlistttupleRtextendRtcoverInclusivetinfotNonetcoverHtmlDirRRtdebugRt
coverBranchestcoverXmlFileRtinttrstriptcoverMinPercentageR R"tTruetworkert
coverInstancet
_warn_no_datat	is_workertexcludetsystmodulestkeystskipModulestcombineterasetloadtstart(R(R%R<R,Rtxtpkgs((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyR5]sp
	

				&		
						

	


cOs-|jjr)|jj�|jj�ndS(s7
        Begin recording coverage information.
        N(RPRRRZR[(R(targstkwargs((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyt
beforeTest�s
cOs-|jjr)|jj�|jj�ndS(s6
        Stop recording coverage information.
        N(RPRRtstoptsave(R(R^R_((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyt	afterTest�s
cCsHtjd�|jj�|jj�|jj�gtjj�D]$\}}|j	||�rD|^qD}tjd|�|jj
|d|�ddl}|jrtjd�y|jj
||j�Wq|jjk
r}tjdt|��qXn|jrltjd�y|jj||j�Wql|jjk
rh}tjd	t|��qlXn|jrDtj�}|jj
|d|�d
}d}	tj||j��}
|
dkr�tj|	|j��}
n|
r4t|
j�d�}||jkrAtjd
|j�tjd�qAqDtjd�ndS(s.
        Output code coverage report.
        sCoverage reports&Coverage report will cover modules: %stfilei����NsGenerating HTML coverage reports"Failed to generate HTML report: %ssGenerating XML coverage reports!Failed to generate XML report: %ss@-------\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.(R9RHRPRaRXRbRTRUtitemstwantModuleCoveragetreportR,RGthtml_reporttmisctCoverageExceptiontwarningtstrRJt
xml_reportRMtStringIOtretsearchtgetvalueRFRKtgroupsR:texit(R(tstreamtnametmoduleRUR,tetftmultiPackageRetsinglePackageRetmt
percentage((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyRg�sJ



	
	
		cCs-t|d�s#tjd|�tSt|j�}|sI|jd�r]tjd|�tS|jr�xf|jD]X}tj	dtj
|�|�rp|js�|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;RR}tendswithR?RotfindalltescapeR>R<t	testMatchRpRNRW(R(RuRvtmodule_filetpackage((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyRf�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(RDR~R?t
startswithRNRF(R(RdR�twant((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pytwantFiles	
N(t__name__t
__module__t__doc__R;R>RFR?RPR=RMtscoreR2R%R5R`RcRgRfR�(((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyRs	:	B			
	6	(R�tloggingRoRTRntnose.plugins.baseRt	nose.utilRRt	getLoggerR�R9R(((s6/usr/lib/python2.7/site-packages/nose/plugins/cover.pyt<module>s