Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/coverage/__pycache__/results.cpython-35.pyc



E�W}%�@shdZddlZddlmZddlmZmZGdd�de�ZGdd�de�Z	dS)	z Results of coverage measurement.�N)�iitems)�format_lines�
SimpleReprc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�Analysisz(The results of analyzing a FileReporter.cs�|�_|�_�jj�_�jj��_�jj��_�jj�j�p]g}�jj|�}�j|�_�jj	�r,t
�jj���_�jj
��_
�jj��_�j�}�j�}t�fdd�t|�D��}tdd�t|�D��}n,g�_i�_
t��_d}}}tdddt�j�dt�j�d	t�j�d
|d|d|��_dS)
Nc3s0|]&\}}|�jkrt|�VqdS)N)�missing�len)�.0�k�v)�self��C/opt/alt/python35/lib64/python3.5/site-packages/coverage/results.py�	<genexpr>!sz$Analysis.__init__.<locals>.<genexpr>css!|]\}}t|�VqdS)N)r)rr	r
rrr
r"sr�n_files��n_statements�
n_excluded�	n_missing�
n_branches�n_partial_branches�n_missing_branches)�data�
file_reporter�filename�lines�
statementsZexcluded_linesZexcludedZtranslate_linesr�has_arcs�sorted�arcs�_arc_possibilities�exit_countsZno_branch_lines�	no_branch�total_branches�missing_branch_arcs�sumr�set�Numbersr�numbers)rrr�executedr�mbarrr)rr
�__init__s8		%"		zAnalysis.__init__cCst|j|j�S)zhThe missing line numbers, formatted nicely.

        Returns a string like "1-2, 5-11, 13-14".

        )rrr)rrrr
�missing_formatted3szAnalysis.missing_formattedcCs
|jj�S)z"Were arcs measured in this result?)rr)rrrr
r;szAnalysis.has_arcscCs|jS)z.Returns a sorted list of the arcs in the code.)r)rrrr
�arc_possibilities?szAnalysis.arc_possibilitiescCs7|jj|j�pg}|jj|�}t|�S)z@Returns a sorted list of the arcs actually executed in the code.)rrrrZtranslate_arcsr)rr(rrr
�
arcs_executedCszAnalysis.arcs_executedcs>�j�}�j����fdd�|D�}t|�S)z;Returns a sorted list of the arcs in the code not executed.c3s4|]*}|�kr|d�jkr|VqdS)rN)r!)r�p)r(rrr
rNsz(Analysis.arcs_missing.<locals>.<genexpr>)r,r-r)r�possiblerr)r(rr
�arcs_missingIszAnalysis.arcs_missingcCs�|j�}|j}tt|��}g}x`|D]X\}}xIt|�D];}||krM|jd||dkr}|ndf�qMWq4Wdj|�S)z�The missing branch arcs, formatted nicely.

        Returns a string like "1->2, 1->3, 16->20". Omits any mention of
        branches from missing lines, so if line 17 is missing, then 17->18
        won't be included.

        z%d->%sr�exitz, )r#rrr�append�join)rrrZ
line_exits�pairs�line�exits�exrrr
�arcs_missing_formattedTs	1zAnalysis.arcs_missing_formattedcs;|j��|j�}�fdd�|D�}t|�S)zAReturns a sorted list of the executed arcs missing from the code.c3sU|]K}|�kr|d|dkr|ddksI|ddkr|VqdS)rrNr)r�e)r/rr
rpsz,Analysis.arcs_unpredicted.<locals>.<genexpr>)r,r-r)rr(Zunpredictedr)r/r
�arcs_unpredictedfszAnalysis.arcs_unpredictedcCsdd�t|j�D�S)z<Returns a list of line numbers that have more than one exit.cSs(g|]\}}|dkr|�qS)rr)r�l1�countrrr
�
<listcomp>ys	z)Analysis.branch_lines.<locals>.<listcomp>)rr )rrrr
�branch_lineswszAnalysis.branch_linescCs tdd�|jj�D��S)z"How many total branches are there?css!|]}|dkr|VqdS)rNr)rr<rrr
r}sz*Analysis.total_branches.<locals>.<genexpr>)r$r �values)rrrr
r"{szAnalysis.total_branchescCse|j�}t|j��}tjt�}x1|D])\}}||kr4||j|�q4W|S)zgReturn arcs that weren't executed from branch lines.

        Returns {l1:[l2a,l2b,...], ...}

        )r0r%r>�collections�defaultdict�listr2)rrr>r)r;�l2rrr
r#szAnalysis.missing_branch_arcscCs}|j�}i}xd|j�D]V}|j|}yt||�}Wntk
r`d}YnX|||f||<qW|S)zGet stats about branches.

        Returns a dict mapping line numbers to a tuple:
        (total_exits, taken_exits).
        r)r#r>r r�KeyError)rZmissing_arcsZstats�lnumr6rrrr
�branch_stats�s

zAnalysis.branch_statsN)�__name__�
__module__�__qualname__�__doc__r*r+rr,r-r0r8r:r>r"r#rFrrrr
rs$rc	@s�eZdZdZdZdZdZddddddddd�Zdd�Ze	d	d
��Z
edd��Zed
d��Z
edd��Zedd��Ze	dd��Zedd��Zdd�Zdd�ZdS)r&z�The numerical results of measuring coverage.

    This holds the basic statistics from `Analysis`, and is used to roll
    up statistics across files.

    rg�?g�X@cCsC||_||_||_||_||_||_||_dS)N)rrrrrrr)rrrrrrrrrrr
r*�s						zNumbers.__init__cCs.|j|j|j|j|j|j|jgS)z:Return a list for __init__(*args) to recreate this object.)rrrrrrr)rrrr
�	init_args�szNumbers.init_argscCsPd|kodkns"t�||_dd||_d|j|_dS)z<Set the number of decimal places used to report percentages.r�
g�?gY@N)�AssertionError�
_precision�_near0�_near100)�clsZ	precisionrrr
�
set_precision�s"	zNumbers.set_precisioncCs|j|jS)z*Returns the number of executed statements.)rr)rrrr
�
n_executed�szNumbers.n_executedcCs|j|jS)z(Returns the number of executed branches.)rr)rrrr
�n_executed_branches�szNumbers.n_executed_branchescCs9|jdkr/|j\}}d||}nd}|S)z/Returns a single percentage value for coverage.rgY@)r�
ratio_covered)r�	numerator�denominatorZpc_covrrr
�
pc_covered�s
zNumbers.pc_coveredcCs�|j}d|ko#|jknr4|j}n=|j|koNdknr_|j}nt||j�}d|j|fS)aReturns the percent covered, as a string, without a percent sign.

        Note that "0" is only returned when the value is truly zero, and "100"
        is only returned when the value is truly 100.  Rounding can never
        result in either "0" or "100".

        r�dz%.*f)rXrOrP�roundrN)rZpcrrr
�pc_covered_str�s		zNumbers.pc_covered_strcCs*d}|jdkr&|d|j7}|S)z/How many characters wide can pc_covered_str be?�rr)rN)rQ�widthrrr
�pc_str_width�szNumbers.pc_str_widthcCs*|j|j}|j|j}||fS)z:Return a numerator and denominator for the coverage ratio.)rSrTrr)rrVrWrrr
rU�szNumbers.ratio_coveredcCs�t�}|j|j|_|j|j|_|j|j|_|j|j|_|j|j|_|j|j|_|j|j|_|S)N)r&rrrrrrr)r�other�numsrrr
�__add__�s	zNumbers.__add__cCs|dkr|StS)Nr)�NotImplemented)rr_rrr
�__radd__szNumbers.__radd__N)rGrHrIrJrNrOrPr*rK�classmethodrR�propertyrSrTrXr[r^rUrarcrrrr
r&�s 

r&)
rJr@Zcoverage.backwardrZ
coverage.miscrr�objectrr&rrrr
�<module>s
�