Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/nose/plugins/cover.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�9�c@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
iZd�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_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_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�tjd�t
|_dSXn||_|j|_|j|_g|_|jrSt|jttf�r
|j}n|jg}x:g|D]}t|�^q D]}|jj|�q6Wn|j|_|jr~tjd|j�nd|_|jr�|j |_tj!d|j�n|j"|_#d|_$|j%r�&|j%j'd	��|_(n|j)r|j*|_$tj!d
|j$�n|jrVt+|jd<|jdt
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_datatbranchtdata_suffix(-tstatustpoptKeyErrorR$Rt	configuretworkertenabledR,thasattrtImportErrortlogterrortFalsetconfRt
coverEraseRt
coverTestst
coverPackagesRt
isinstancetlistttupleRtextendRtcoverInclusivetinfotNonetcoverHtmlDirRRtdebugRt
coverBranchestcoverXmlFileRtinttrstriptcoverMinPercentageR R"tTruet
coverInstance(R(R%R<R,Rtxtpkgs((s6/sys/lib/python2.7/site-packages/nose/plugins/cover.pyR4]sZ
		

				&		
						
cCs�tjd�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(
R9RHtsystmodulestkeystskipModulesR=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|�|jr�tjd�|jj||j�n|j
r�jd�|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(R9RHROtstopRVtsaveRRRStitemstwantModuleCoveragetreportRGthtml_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|js�|jj
j|�rptjd|�tSqpWn||jkr�jd|�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(RkRltmodule_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<module>s

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.